google / google-api-javascript-client

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

initTokenClient never calls call back. #926

Open ulao opened 1 year ago

ulao commented 1 year ago

I'm trying to use this new auth method and nothing seems to work.

Summary no callback is fired during auth.

Browser(s)/Version(s) Chrome latest

Expected Behavior a call back

Actual Behavior no call back

Steps to Reproduce This is my code

client = google.accounts.oauth2.initTokenClient({ client_id: CLIENT_ID, scope: 'https://www.googleapis.com/auth/spreadsheets.readonly', callback: (tokenResponse) => { access_token = tokenResponse.access_token; gapi.client.setApiKey(API_KEY); gapi.load('client', test() );

          },
    })

I can alert the function google.accounts.oauth2.initTokenClient and it has loaded. but nothing is running in the call back function

rossMac96 commented 1 year ago

@ulao did you ever find a workaround for this? having the same issue. can get the sign in popup to work just fine, but once it closes, the callback is not invoked.

rossMac96 commented 1 year ago

For people struggling with this issue, it seems that Google wants your site to either be http, or https with a real (not self signed) certificate. I can't find any documentation that points to this requirement, but I tried changing my https (self signed cert) over to http, and the callback is now firing as expected.

LiubomyrB commented 10 months ago

In my case, it doesn't fire callback because of Header set Cross-Origin-Opener-Policy "same-origin".

dkudumovic1 commented 8 months ago

What worked for me was adding an error_callback. It helped me to understand why my callback wasn't being called.