How can I login in with another Google account #3795
-
Question 💬When I logged in with a google account, and then sign out, finally sign in again, it will automatically sign in with the previous account, I have no chance to choose which account I'd like to use. How to reproduce ☕️https://next-auth-example.vercel.app/ Contributing 🙌🏽No, I am afraid I cannot help regarding this |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
This is not related to NextAuth.js, but how OAuth usually works by default. https://next-auth.js.org/getting-started/client#additional-parameters |
Beta Was this translation helpful? Give feedback.
-
I've read this answer before and didn't understand it and I know of other teams that switched from using next-auth because they can't solve this issue. The answer to this is to prompt the user to login.(As stated in the documentation) What I did was to create a component that is displayed if you are not logged in. On this component I have a button that calls the signIn function from 'next-auth/react'. Here I am using Azure as my OAuth provider. You can swap out "azure-ad" for "google" if Google is your provider. The <Button onClick={() => signIn("azure-ad", { callbackUrl: "/dashboard" }, { prompt: "login" })}>
Sign in with Azure Active Directory
</Button> |
Beta Was this translation helpful? Give feedback.
-
@damain thank you for your answer! This worked for me for both Azure and Google logins. |
Beta Was this translation helpful? Give feedback.
This is not related to NextAuth.js, but how OAuth usually works by default.
https://next-auth.js.org/getting-started/client#additional-parameters
https://www.oauth.com/oauth2-servers/authorization/requiring-user-login/#:~:text=In%20Google%E2%80%99s%20API,prompt%3Dlogin