使用GIS (Google Identity Services)和API子包(picker),没有客户端包



我目前正在替换gapi.oauth2包,根据指南使用TokenClient,一切正常。

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({});

唯一的问题是我们没有使用gapi.client,并且希望避免加载该包,因为我们只使用令牌来显示使用google.picker.PickerBuilder的选择器。现在,在初始化之后,GSI包试图使用gapi.client.setToken(),这显然失败了,因为包没有加载。

[GSI_LOGGER-TOKEN_CLIENT]: Set token failed.日志含义Gapi.client.setToken定义。

所以现在我找不到任何关于如何防止该调用发生的参考资料,也没有如何至少通过不例如在noop中作为占位符来抑制警告。

有没有人知道有什么官方的方法来处理这个问题?

在我的测试中,访问令牌成功返回给回调处理程序。

它看起来是一个错误生成的警告,恼人的是的,但功能上你是好的。之后的正式发布应该会删除警告,而不需要您采取任何行动。

GIS (Google Identity Services)的新API可能会删除gapi的setToken。我必须通过代码来修复它。

gapi = {client: {setToken: function(){ return; }}}; 

最新更新