使用GIS(Google Identity Services)和API子包(Picker),而无需客户端包
我目前正在根据 tokenclient
根据 tokenclient 来替换 gapi.oauth2
软件包。 Web/指南/迁移到GIS“ rel =“ noreferrer”>指南,一切正常。
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.picker.pickerbuilder 。
现在,在初始化之后,GSI软件包试图使用
gapi.client.settoken()
,显然由于没有加载软件包而失败。
[gsi_logger-token_client]:设置令牌失败。 gapi.client.settoken undefined。
因此,现在我找不到有关如何防止发生这种情况的任何内容代码>作为占位符。
有谁知道是否有任何官方方法来处理?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我的测试中,访问令牌已成功返回到回调处理程序。
它看起来是一个错误生成的警告,令人讨厌的是,但是从功能上看,您还可以。后来的官方发布应删除警告,而无需采取任何措施。
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.
GIS的新API(Google Identity Services)可能会删除GAPI的销售。
我必须通过代码修复它。
The new API of GIS (Google Identity Services) maybe remove the setToken of the gapi.
I had to fix it by the code.