OWIN Authentication with Google

2019-07-18 21:53发布

问题:

I'm using owin authentication on an ASPNET MVC project. When using google I have the following problem:

1- The user signs in with the google account

2- The user signs out

3- The next time the user tries to sign in, the current google account is automatically used to sign in again without prompting the user is he wants to use another account.

Question: How can I, using the owin google authentication, prompt the user if he wants to use the current account or use a different one?

Thanks

回答1:

If you are using external login provider (Google in your case) to sign in to your application, then your application will get authenticated by third party provider (Google in your case).

After successful registration asp.net identity framework store provider key return from third party provider in AspNetUserLogins table which will be used when sign in next time.

But the user sign out from your application does not means that the user sign out from Google. Because of that if you are using the same browser which is already authenticated for your Google account will allow you to login to your application using the already authentication Google account.

There is no simple out of the box option in Asp.Net identity framework to sign out from both external provider (Google) and your application when you are calling sign out in your application.

You have to call Google API to sign out from Google account when you are calling sign out in your application in order to achieve your requirement.

You can see this work item to get more details on this.