ASP.Net Identity provider requesting too much info

喜欢而已 提交于 2019-12-12 12:25:20

问题


I have asp.net indentity working fine. However when a user logs in, Google asks the user if it's OK to provide the following information:

- View your email address
- View basic information about your account

The problem is that I don't even want that information. I just want a unique way to identify the user (which it does provide). I don't want users thinking i'm going to spam them when they sign in.

In Startup.Auth.cs I use a very vanilla google setup:

app.UseGoogleAuthentication();

EDIT: SOLUTION

Brock's answer led me to the correct solution. Key thing was adding "openid" to the scope.

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

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

    app.UseGoogleAuthentication(googleOAuth2AuthenticationOptions);

回答1:


In the Katana v2 middleware the Google support was only Open ID and it was hard coded to request email.

In v2.1 they now have OAuth2 support, which means the GoogleAuthenticationOptions has a scopes property which allows you to control what you're asking from google. But this means you need to setup your client app like any other OAuth2 provider (so you need to register and get a client id/secret).



来源:https://stackoverflow.com/questions/21956365/asp-net-identity-provider-requesting-too-much-info

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!