React-google-login: Is there anyway to force an account selection screen on login?

Created on 17 Jan 2021  路  4Comments  路  Source: anthonyjgrove/react-google-login

Really enjoying the library so far! I am following this medium tutorial (Link) that really doesn't deviate much from the basic configuration of setting up a login and logout button

<GoogleLogin
        clientId={clientId}
        buttonText="Login"
        onSuccess={onSuccess}
        onFailure={onFailure}
        cookiePolicy={'single_host_origin'}
        style={{ marginTop: '100px' }}
        isSignedIn={true}
    />
    <GoogleLogout
        clientId={clientId}
        buttonText="Logout"
        onLogoutSuccess={onSuccess}
    />

I can successfully login and logout however after the first login/logout I am no longer prompted to re-enter my password /email
and I it just automatically signs into the account I previously logged in as.

I am on version "react-google-login": "^5.2.2",
and the codebase in the tutorial is using "react-google-login": "^5.1.20".

I tested in all relevant browsers and the same thing is occuring;
in the deployed example of the tutorial Link even when I login for the first time and logout each subsequent login prompts me to choose which account I want (the behavior I desire) I can see the popup for sign in for the tutorial is pointed at the URL
https://accounts.google.com/_o/oauth2/auth/oauthchooseaccount_?redirect_uri = .....

Whereas using my version of this library will point to the URL
https://accounts.google.com/o/oauth2/auth?redirect_uri= ....

Is there anyway to get the account selection URL back, maybe as a prop?

Most helpful comment

Hello @ethanny2 @dvnecroillusion ! I found a way to force it, juste add prompt="select_account" in the props of the GoogleLogin component, just like this:

```
clientId={CLIENT_ID}
className="google_sign_in"
buttonText="Sign in with Google"
onSuccess={this.onLoginSuccess}
onFailure={this.onLoginFailure}
cookiePolicy="single_host_origin"
prompt="select_account"
/>
````

All 4 comments

Hello! I have the same problem here. I need to force the account selection because I use google login to authenticate users trough their company gmail and users can't select the correct email if they are already logged in with some other google account on their browser.
Thanks!

Hello @ethanny2 @dvnecroillusion ! I found a way to force it, juste add prompt="select_account" in the props of the GoogleLogin component, just like this:

```
clientId={CLIENT_ID}
className="google_sign_in"
buttonText="Sign in with Google"
onSuccess={this.onLoginSuccess}
onFailure={this.onLoginFailure}
cookiePolicy="single_host_origin"
prompt="select_account"
/>
````

Hello @ethanny2 @dvnecroillusion ! I found a way to force it, juste add prompt="select_account" in the props of the GoogleLogin component, just like this:

<GoogleLogin
    clientId={CLIENT_ID}
    className="google_sign_in"
    buttonText="Sign in with Google"
    onSuccess={this.onLoginSuccess}
    onFailure={this.onLoginFailure}
    cookiePolicy="single_host_origin"
    prompt="select_account"
/>

It works, thanks a lot!

Yes I think I missed that prop from the documentation; thanks for the help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SSR
rlancer picture rlancer  路  8Comments

MiLeung picture MiLeung  路  4Comments

scolyer picture scolyer  路  3Comments

foncyc picture foncyc  路  5Comments

Ethan0007 picture Ethan0007  路  3Comments