這可能會是一個可怕的問題,但我不知道從哪裏開始解決這個問題。我沒有觸及集成LinkedIn與我的webapp的任何代碼,但它只是開始拋出無效的重定向uri錯誤。我正在使用this stuff在我的應用程序中獲取linkedIn。這裏是我的startup.auth.cs文件(顯然鍵屏蔽):LinkedIn在asp.net中的oauth mvc5應用程序停止工作
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(options: new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
ExpireTimeSpan = new TimeSpan(0,0,30,0),
LoginPath = new PathString("/Account/Access"),
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
var linkedInOptions = new LinkedInAuthenticationOptions
{
ClientId = "fooooooooo",
ClientSecret = "barrrrrrrr",
Provider = new LinkedInAuthenticationProvider
{
OnAuthenticated = context =>
{
context.Identity.AddClaim(new Claim("LinkedInAccessToken", context.AccessToken));
return Task.FromResult(0);
}
}
};
linkedInOptions.Scope.Add("r_fullprofile");
app.UseLinkedInAuthentication(linkedInOptions);
}
在我的帳戶控制器這是它打它得到錯誤信息之前:
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult ExternalLogin(string provider, string returnUrl)
{
// Request a redirect to the external login provider
return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { returnUrl }));
}
中,變量「 RETURNURL」爲空,但低於redirectUri是‘/帳號/ ExternalLoginCallback’
private class ChallengeResult : HttpUnauthorizedResult
{
public ChallengeResult(string provider, string redirectUri)
: this(provider, redirectUri, null)
{
}
public ChallengeResult(string provider, string redirectUri, string userId)
{
LoginProvider = provider;
RedirectUri = redirectUri;
UserId = userId;
}
public string LoginProvider { get; set; }
public string RedirectUri { get; set; }
public string UserId { get; set; }
public override void ExecuteResult(ControllerContext context)
{
var properties = new AuthenticationProperties() { RedirectUri = RedirectUri };
if (UserId != null)
{
properties.Dictionary[XsrfKey] = UserId;
}
context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);
}
}
有什麼你看到的可能是有問題的?我應該查看哪些字段以解決此錯誤?當我搜索錯誤時,它只是提供了有關在linkedin上創建應用程序的通用答案,我已經這樣做了。
謝謝!這就是我需要的! –