Identity Toolkit for Websites v3添加access_type = offline以继续param值?

时间:2016-03-19 16:11:38

标签: java google-oauth2 google-identity-toolkit google-identity

Identity Toolkit for Websites v3提供授权代码signInSuccess回调tokenString参数。

虽然//www.gstatic.com/authtoolkit/js/gitkit.js是混淆和未记录的,但我发现.gstatic.com / authtoolkit / js / gitkit-debug.js 哪个应该有所帮助,但如果有更好的方法或者我错过了什么,我仍然很好奇。

问题是我找不到设置参数access_type = offline的方法所以我无法获得刷新令牌,所以使用Google API Client Library for Java,使用idp google.com登录后似乎不是一个选项。 我无法使用提供的联合登录解决方案。我需要单独实施谷歌提供商oauth流程...我不敢相信我必须在这里遗漏一些东西。

如果我不能使用它来访问其他谷歌API,那么提供对网址#中授权代码的访问权有什么意义。

在任何情况下,在2012年,有人遇到了同样的问题,在[this] [2]论坛讨论中看到了为v1提供的解决方案。

响应以“不同IdP有不同方式获取刷新令牌”开头,即对于Microsoft,需要“wl.offline_access”范围;对于Google,需要“access_type = offline”URL参数。目前GITKit还没有采用标准化的方法来做到这一点,但我们正在研究它。“

如果他们在2012年对它进行调查肯定会有某种方法......无论如何我的要求目前只是访问google api。

因此,比较google oauth playground的流量,您可以选择access_type = offline和帐户选择器url continue ...看起来像这样

 https://accounts.google.com/AccountChooser?continue=https://accounts.google.com/o/oauth2/auth?
access_type=offline
&approval_prompt=force
&scope=https://www.googleapis.com/auth/cloudprint+https://www.googleapis.com/auth/userinfo.profile
&response_type=code
&redirect_uri=https://developers.google.com/oauthplayground
&client_id=407408718192.apps.googleusercontent.com
&hl=en-GB
&from_login=1
&as=5cc2df3c88f13395
&ltmpl=popup
&btmpl=authsub
&hl=en_GB
&scc=1
&oauth=1

您可以在哪里看到access_type参数。 我在所有正确的位置向gitkit-debug.js添加了一些额外的配置属性,然后跟踪执行步进函数,直到POST被发送,即使我的新参数都在数据中一直到发送,直到它被发送我得到一个不包含它们的网址

screeenshot of debug console showing data object state just before POST

我的结果url continue参数看起来像这样

https://accounts.google.com/AccountChooser?continue=https://accounts.google.com/o/oauth2/auth?
scope=https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/cloudprint+https://www.googleapis.com/auth/userinfo.profile+openid
&response_type=token+code+id_token+gsession
&redirect_uri=http://localhost:8080/identity/control/authenticate
&state=AFD_5tmV........... etc
&client_id=143312559437-4o93ranlfalg78rj006qirib182bnkj4.apps.googleusercontent.com
&include_profile=true
&hl=en-GB
&from_login=1
&as=77237587f41849c5
&ltmpl=popup
&btmpl=authsub
&hl=en_GB
&scc=1
&oauth=1

为什么以及如何删除access_type =离线?

1 个答案:

答案 0 :(得分:0)

IO