我遇到了一個必須與Microsofts Open Id提供者集成的應用程序的嚴重問題。微軟OpenId登錄
我正在使用ASP.NET MVC 5與Microsoft.Owin庫。我的Startup.Auth文件看起來像這樣:
app.UseMicrosoftAccountAuthentication(new MicrosoftAccountAuthenticationOptions()
{
ClientId = ConfigurationManager.AppSettings["msClientId"],
ClientSecret = ConfigurationManager.AppSettings["msClientSecret"]
});
因此,我做了以下請求我的外部登錄MVC行動。
[HttpGet]
public ActionResult ExternalLogin(string provider, string connectionId)
{
return new ChallengeResult(Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(provider), Request.Url.GetLeftPart(UriPartial.Authority) + "/Login/ExternalLoginCallback?connectionId=" + connectionId);
}
我的班級挑戰的結果是這樣的:
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);
}
}
可惜我馬上我重定向到Microsoft帳戶登錄我只是得到:
爲輸入參數提供的值「REDIRECT_URI '無效。預期值爲'https://login.live.com/oauth20_desktop.srf'或與此客戶端應用程序註冊的重定向URI匹配的URL。 &狀態= 9Y9inDc4SVQTd_I4ZoLwuLPTZa5i-4NapEWzuspU9B_jz1t4aXfPY239FXx2xyI-v9xW-0fgU0kwsZVzYXOtiPhoGH9_h4aiS2Q7FlJGFNviREMLRNnfHfeYoG0m0wSgO7ZZcsJztIcgPEPdo70HkN4mCynng6bx7-nR6i7WN7DQ0SYRXrxmb2hhHDvxTWeTQAfpxKWAezJzDqdEfhoDx1VyRGC-5pCxVbhB5VF2Sb9x5TL0KWb4tXgjYSHbejDlzwMQfgcVf0SB0qRRIi2YNCEbWi6_KbGADRCN-DZ7rpVd_n695nRNQXwhQvYHTqAJr3L1dny3NvbCmYJ9SRIt6w
由於實際URL。該頁面只是說出現了技術問題。我有點不知所措。
我檢查了該請求發送到實際的MS提供商,它看起來像這樣: (注取代成明顯的安全問題)
但我檢查客戶端編號是正確的, redirect_uri參數與我在MS帳戶設置中設置的參數相匹配。
/oauth20_authorize.srf?client_id= &範圍= wl.basic & RESPONSE_TYPE =代碼& REDIRECT_URI = &狀態= zFGr4tzGDqMUpH7yVp0dB8JNoM_D6SFSiLa3NoKhF15O5mAkW7N51wB9vjzs1_PR7WQewUWYjLxfHY865EwN3EuEVIHp_S4m_q32s9DPG_dNsZ_wdEsOUe7FE3VY16jPS6WWeI-VnMu12RXvIqVnvH9tVXVc8QLUe8s1sZc5HFYWCtqiyejmw-MKO4MV1_DRoisn2lAO6rRhvyT-LvZBzZ20-CiFkxmVhq8DzdCnFn3Ya7sWyNzTzu1d1u_q71VBY_ot5sqUx-YEvLqcaNwDOHmFUVTpe5ynVKc8203pxqwlpNbfy8hrqxBuJWAGhiHuOIAMo5HuRv8kJJgmGOz4OQ
預先感謝。
這是在開發環境?什麼是您的應用程序使用的URL,你是否在主機文件中設置了一個並使用本地IIS? – DSR 2014-11-07 11:49:25
嗨,是的,嘗試了開發環境和本地環境。我們在重定向特定網址的網絡上有一條規則。 localhost.xxx.com改爲127.0.0.1。我試過一個實時網址,但都沒有成功。兩者都會因相同的問題而失敗:-( – 2014-11-07 12:02:56