What should be used instead of UseGoogleAuthentication (IAppBuilder) method?

The MSDN documentation indicates that:

GoogleAuthenticationExtensions.UseGoogleAuthentication Method (IAppBuilder)

Note. This API is now deprecated .

What is the alternative? What should you use instead of this method?

+3


source to share


1 answer


You can use Google OAuth2 middleware like this:

private void ConfigureAuth(IAppBuilder app)
{
    var cookieOptions = new CookieAuthenticationOptions
    {
        LoginPath = new PathString("/Account/Login")
    };

    app.UseCookieAuthentication(cookieOptions);

    app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType);

    app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions
    {
        ClientId = ConfigurationManager.AppSettings["ClientId"],
        ClientSecret = ConfigurationManager.AppSettings["ClientSecret"]
    });
}

      



You can create a client ID and client secret: https://console.developers.google.com/

+5


source







All Articles