2014-11-06 4 views
0

Microsoft Open ID 제공 업체와 통합해야하는 앱에 심각한 문제가 있습니다.Microsoft 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입니다. & 상태 = 실제 URL로 9Y9inDc4SVQTd_I4ZoLwuLPTZa5i-4NapEWzuspU9B_jz1t4aXfPY239FXx2xyI-v9xW-0fgU0kwsZVzYXOtiPhoGH9_h4aiS2Q7FlJGFNviREMLRNnfHfeYoG0m0wSgO7ZZcsJztIcgPEPdo70HkN4mCynng6bx7-nR6i7WN7DQ0SYRXrxmb2hhHDvxTWeTQAfpxKWAezJzDqdEfhoDx1VyRGC-5pCxVbhB5VF2Sb9x5TL0KWb4tXgjYSHbejDlzwMQfgcVf0SB0qRRIi2YNCEbWi6_KbGADRCN-DZ7rpVd_n695nRNQXwhQvYHTqAJr3L1dny3NvbCmYJ9SRIt6w

. 이 페이지는 기술적 문제가 발생했다고 말합니다. 나는 약간의 손실이 있습니다.

내가 요청이 실제 MS 제공자에게 보낸 확인했습니다 그것은 다음과 같습니다 (주 치환을 명백한 보안 문제에 대한)

하지만 클라이언트 ID가 올바른 것을 확인했는데 redirect_uri 매개 변수는 MS 계정 설정에서 설정 한 매개 변수와 일치합니다. wl.basic = & RESPONSE_TYPE

/oauth20_authorize.srf?client_id= 범위 = & & 코드를 redirect_uri = 미리 = zFGr4tzGDqMUpH7yVp0dB8JNoM_D6SFSiLa3NoKhF15O5mAkW7N51wB9vjzs1_PR7WQewUWYjLxfHY865EwN3EuEVIHp_S4m_q32s9DPG_dNsZ_wdEsOUe7FE3VY16jPS6WWeI-VnMu12RXvIqVnvH9tVXVc8QLUe8s1sZc5HFYWCtqiyejmw-MKO4MV1_DRoisn2lAO6rRhvyT-LvZBzZ20-CiFkxmVhq8DzdCnFn3Ya7sWyNzTzu1d1u_q71VBY_ot5sqUx-YEvLqcaNwDOHmFUVTpe5ynVKc8203pxqwlpNbfy8hrqxBuJWAGhiHuOIAMo5HuRv8kJJgmGOz4OQ

감사 & 상태.

+0

이 개발 환경에 도움이

app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); 

희망이 줄을 제거해야? 앱에 사용하는 URL은 무엇이며 호스트 파일에 하나를 설치하고 로컬 IIS를 사용 했습니까? – DSR

+0

안녕하세요, 예 dev 환경과 로컬 환경을 모두 시도했습니다. 특정 URL을 리디렉션하는 규칙이 네트워크에 있습니다. localhost.xxx.com을 127.0.0.1로 변경하십시오. 라이브 URL을 시도했지만 어느 것도 작동하지 않는 것 같습니다. 둘 다 같은 문제로 실패합니다 .-( –

답변

0

실제로 로컬 URL은 somthing.something.com과 비슷해야합니다. 올바르게 사용하면 UseMicrosoftAccountAuthentication을 새 개체를 만들지 않고 직접 사용해보십시오.

app.UseMicrosoftAccountAuthentication(
       clientId: ConfigurationManager.AppSettings["msClientId"], 
       clientSecret: ConfigurationManager.AppSettings["msClientSecret"]); 

더 이상 앱에/signin-microsoft라는 리디렉션 URL을 올바르게 설정해야합니다.

this 문서를 올바르게 따르십시오.

희망이 도움이됩니다.내 경우

0

나는 푸른 Active Directory에의 오픈 ID를 사용하기 때문에 나는이 안부