2014-02-22 3 views
4

asp.net indentity 잘 작동합니다. 사용자가 로그인 그러나 때 다음과 같은 정보를 제공 할 수있는 상태인지, 구글이 사용자에게 요청 :ASP.Net ID 공급자가 너무 많은 정보 요청

을 - 귀하의 이메일 주소를 볼
- 계정

문제에 대한 기본 정보보기는 그 I 돈 그 정보를 원한다. 나는 사용자를 식별 할 수있는 독특한 방법을 원한다. 나는 사용자가 나는 그들이 로그인 할 때 그들을 스팸거야 생각하지 않으 Startup.Auth.cs에서

나는 매우 바닐라 구글 설정을 사용합니다.

app.UseGoogleAuthentication(); 

편집 : 솔루션

브록 (Brock)의 대답으로 올바른 해결책을 찾았습니다. 중요한 것은 "openid"를 범위에 추가하는 것이 었습니다.

var googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions 
     { 
      ClientId = "XXXX", 
      ClientSecret = "YYYY", 
      CallbackPath = new PathString("/Account/LoginCallback/"), 
     }; 

    googleOAuth2AuthenticationOptions.Scope.Add("openid"); //!Important 

    app.UseGoogleAuthentication(googleOAuth2AuthenticationOptions); 
+0

이것은 http://www.symbolsource.org/Public/Metadata/NuGet/Project/Microsoft.Owin.Security.Google/2.1.0-rc1/Release/.NETFramework,Version%3Dv4.5/에서 작동합니다. Microsoft.Owin.Security.Google/Microsoft.Owin.Security.Google/GoogleOAuth2AuthenticationHandler.cs?ImageName=Microsoft.Owin.Security.Google 기본 범위는 입니다. scope = "openid profile email"; –

+0

좋아요, googleOAuth2AuthenticationOptions.Scope.Add ("openid")가 작동합니다. 이메일 권한 만 원하는 경우. 사용 ("openid 이메일") –

답변

3

Katana v2 미들웨어에서 Google 지원은 Open ID 일 뿐이며 전자 메일을 요청하기 위해 하드 코딩되었습니다.

v2.1에서는 이제 OAuth2가 지원됩니다. 즉, GoogleAuthenticationOptions에는 사용자가 Google에서 요청하는 내용을 제어 할 수있는 범위 속성이 있습니다. 그러나 이것은 다른 OAuth2 제공자와 마찬가지로 클라이언트 애플리케이션을 설정해야한다는 것을 의미합니다 (따라서 클라이언트 id/secret를 등록하고 얻어야합니다).