Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

The MSDN documentation states that:

GoogleAuthenticationExtensions.UseGoogleAuthentication Method (IAppBuilder)

Note: This API is now obsolete.

What's the alternative? What should be used instead of this method?

like image 461
B Faley Avatar asked Dec 03 '25 00:12

B Faley


1 Answers

You can use the 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 secret at: https://console.developers.google.com/

like image 137
MvdD Avatar answered Dec 04 '25 15:12

MvdD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!