google / google-api-javascript-client

Google APIs Client Library for browser JavaScript, aka gapi.
Apache License 2.0
3.2k stars 1.06k forks source link

Authorization code flow keeps prompting consent screen users #1210

Open alejo-webel opened 6 months ago

alejo-webel commented 6 months ago

Summary I'm using the authorization code flow as the sign in method in my Angular web app and i'm finding that after every login, the consent screen is always shown, no matter if it is the Nth sign in attempt of a same user.

According to the google documentation, I understand that this consent screen should only appear once per user (After the first token request).

Expected Behavior The consent screen should only appear once per user.

Actual Behavior The consent screen is appearing every time while signing in.

Code (Simplified sample)

var googleClient

function initGoogle(): void {

googleClient = google['accounts'].oauth2.initCodeClient({
          client_id: 'XXX',
          ux_mode: 'popup',
          scope:
            'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email',
          callback: ({ code }) => {
            myAuthCodeHandler(code);
          },
        });

}

function triggerAuthorizationFlow(): void {

googleClient.requestCode();

}

And I'm importing the google gsi client at my head tag:

<script src="https://accounts.google.com/gsi/client" async defer></script>

Does anybody is having the same issue? I need to keep using the authorization code flow but with the expected beehaviour mentioned above.

Thanks

sergeydus commented 3 weeks ago

experiencing the same thing