Reputation: 61
I am currently replacing the gapi.oauth2
package, by using the TokenClient
according to the guide and everything works fine.
global.google.accounts.oauth2
.initTokenClient({
client_id: CONFIG.google.clientId,
scope: 'https://www.googleapis.com/auth/drive.readonly',
ux_mode: 'popup',
callback(tokenResponse) {
if (tokenResponse && !tokenResponse.error) {
onSuccess(tokenResponse.access_token);
return;
}
onError(tokenResponse.error || 'google authentication failed');
},
})
.requestAccessToken({});
The only issue is that we are not using the gapi.client
and would prefer avoiding loading that package as we are only using the token to show a picker by using google.picker.PickerBuilder
.
Now after the initialization the GSI package tries to use gapi.client.setToken()
which obviously fails as the package is not loaded.
[GSI_LOGGER-TOKEN_CLIENT]: Set token failed. Gapi.client.setToken undefined.
So now i could not find anything in the reference on how to prevent that call to happen, nor how to at least suppress the warning by not e.g hacking in a noop
as a placeholder.
Does anyone know if there is any official way to deal with that ?
Upvotes: 6
Views: 1444
Reputation: 11
The new API of GIS (Google Identity Services) maybe remove the setToken of the gapi. I had to fix it by the code.
gapi = {client: {setToken: function(){ return; }}};
Upvotes: 1
Reputation: 565
In my tests the access token is successfully returned to the callback handler.
It looks to be an incorrectly generated warning, annoying yes, but functionally you're okay. A later, official release should remove the warning with no action on your part required.
Upvotes: 1