选择器 API - 手动设置 access_token
Picker API - manually set access_token
我正在尝试使用 Picker
API 和 this guide,并且遵循指南可以正常工作。
但是,我的应用使用 Google 登录本身来登录用户。因此,本指南中的 auth
步骤是多余的,因为当用户登录时我已经有了一个 access_token
(我通过使用节点 js 在服务器上交换 auth_code
来获得这个google api 客户端库)。但是,当我尝试调用函数 setOAuthToken(oauthToken)
时,使用 access_token 的旧值,它向我显示此屏幕而不是选择器,要求我再次登录。
我哪里做错了。
可能是因为您正在使用 Google 登录(它传递生成的 ID 令牌)和身份验证 API(来自您正在使用的指南)。您可以参考这个thread手动设置。
gapi.auth.setToken({
access_token: "YOUR_TOKEN_HERE"
});
In fact this token object is the same as the one you get within the gapi.auth.authorize() callback. So if something doesn't works as expected, you can add more attributes from there to make it work.
希望对您有所帮助。
原来这是一个 scope
问题 -
我没有使用授予的新范围(使用驱动器的权限)更新我的 refresh_token
/access_token
setOAuthToken(access_token)
工作正常
我正在尝试使用 Picker
API 和 this guide,并且遵循指南可以正常工作。
但是,我的应用使用 Google 登录本身来登录用户。因此,本指南中的 auth
步骤是多余的,因为当用户登录时我已经有了一个 access_token
(我通过使用节点 js 在服务器上交换 auth_code
来获得这个google api 客户端库)。但是,当我尝试调用函数 setOAuthToken(oauthToken)
时,使用 access_token 的旧值,它向我显示此屏幕而不是选择器,要求我再次登录。
我哪里做错了。
可能是因为您正在使用 Google 登录(它传递生成的 ID 令牌)和身份验证 API(来自您正在使用的指南)。您可以参考这个thread手动设置。
gapi.auth.setToken({ access_token: "YOUR_TOKEN_HERE" });
In fact this token object is the same as the one you get within the gapi.auth.authorize() callback. So if something doesn't works as expected, you can add more attributes from there to make it work.
希望对您有所帮助。
原来这是一个 scope
问题 -
我没有使用授予的新范围(使用驱动器的权限)更新我的 refresh_token
/access_token
setOAuthToken(access_token)
工作正常