google/google-api-javascript-client

initTokenClient never calls call back.

ulao opened this issue · 5 comments

ulao commented

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

@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.

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.

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

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