4
我有asp.net的indentity工作的罰款。然而,當一個用戶登錄時,谷歌會詢問用戶是否確定要提供以下信息:ASP.Net身份提供商請求太多信息
- 查看你的電子郵件地址
- 查看有關您的帳戶
問題的基本信息是,我不甚至不需要那些信息。我只想要一種獨特的方式來識別用戶(它提供的)。我不想讓用戶以爲我要去垃圾郵件他們,當他們登錄
在Startup.Auth.cs我用一個很香草谷歌設置:
app.UseGoogleAuthentication();
編輯:解
布羅克的回答讓我找到了正確的解決方案。關鍵是將「openid」添加到範圍中。
var googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions
{
ClientId = "XXXX",
ClientSecret = "YYYY",
CallbackPath = new PathString("/Account/LoginCallback/"),
};
googleOAuth2AuthenticationOptions.Scope.Add("openid"); //!Important
app.UseGoogleAuthentication(googleOAuth2AuthenticationOptions);
這是因爲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默認範圍是 範圍=「OpenID的個人資料的電子郵件」; –
很好,googleOAuth2AuthenticationOptions.Scope.Add(「openid」)的作品。如果你只想要電子郵件許可。使用(「openid電子郵件」) –