在YouTube上看了国际海事组织有帮助的GDL剧集后,我最近才能够重构我的应用程序引擎应用程序以支持云端点。
我正在测试我的网站,使用javascript客户端来处理授权,然后返回一个项目列表,大多数项目都可以正常工作。但是,当我调用端点返回项目列表时,我在App Engine日志中得到以下错误集:
I 2013-03-14 08:52:14.748 Checking for id_token.
W 2013-03-14 08:52:14.748 id_token verification failed: Wrong number of segments in token: ya29.AHES6ZSpbeiTPTOJhCTtRdypgldcrRBQBKH8oQ8Y_FpxG5-Lr3OW6dE
I 2013-03-14 08:52:14.748 Checking for oauth token.
W 2013-03-14 08:52:14.885 Found 1 RPC request(s) without matching response (presumably due to timeouts or other errors)据我所知,在google返回的所有身份验证令牌中只有2个“段”,而不是3个,所以我不清楚这是什么意思。
下面是来自我的浏览器控制台的授权请求头:授权载体ya29.AHES6ZSpbeiTPTOJhCTtRdypgldcrRBQBKH8oQ8Y_FpxG5-Lr3OW6dE
任何帮助都将不胜感激。
发布于 2013-03-15 03:03:02
有两种类型的令牌: ID令牌和标准持有者令牌。
持有者令牌:
这是通过OAuth舞蹈检索到的标准令牌。
ID令牌:
典型的ID令牌看起来类似于eyJhbGciOiJSUzI1NiIsImtpZCI6IjIxZWFlMTVkODE.eyJpc3MiOiJhY2NvdW50cy5n.oXLawgz_ed (除了具有更长的段),并且是一个带符号的JWT。
在JavaScript中,可以通过将'id_token'添加到响应类型来获得ID令牌,就像我们的Tic-Tac-Toe sample中所做的那样。
这样,OAuth请求的returned from令牌也将有一个ID令牌:
var token = gapi.auth.getToken();
// Use id_token instead of bearer token
token.access_token = token.id_token; 您在日志中看到的内容:
这条线
W 2013-03-14 08:52:14.748 id_token verification failed: Wrong number of segments in token: ya29.AHES6ZSpbeiTPTOJhCTtRdypgldcrRBQBKH8oQ8Y_FpxG5-Lr3OW6dE仅为警告,表示观察到的令牌ya29.AHE...不是ID令牌,日志中的下一行
I 2013-03-14 08:52:14.748 Checking for oauth token.意味着它将继续检查令牌是否为持有者令牌。
这个并不意味着你的令牌是无效的,只是它正在检查持有者令牌。
这条线
W 2013-03-14 08:52:14.885 Found 1 RPC request(s) without matching response (presumably due to timeouts or other errors)可能表示存在RPC来验证失败的令牌。验证持有者令牌的主要部分是调用
oauth.get_current_user(EMAIL_SCOPE)和一个请求
https://www.googleapis.com/oauth2/v2/tokeninfo?access_token=ya29.AHE...验证令牌上的客户端ID和访问群体。
ID令牌深度:
第一段是所使用的加密的base64url编码描述。例如。
>>> import base64, json
>>> segments = id_token.split('.')
>>> first_segment = segments[0] + '=' * ((4 - len(segments[0])) % 4)
>>> json.loads(base64.urlsafe_b64decode(first_segment))
{u'alg': u'RS256', u'kid': u'21eae15d817c1b4a8f6ff4501930512d07cbe684'}第二个片段是令牌内容的base64url编码描述:
>>> second_segment = segments[1] + '=' * ((4 - len(segments[0])) % 4)
>>> base64.urlsafe_b64decode(second_segment)
{u'at_hash': u'xxxyyyzzz', # Fake Data
u'aud': u'someclient_id.apps.googleusercontent.com',
u'azp': u'someclient_id.apps.googleusercontent.com',
u'cid': u'someclient_id.apps.googleusercontent.com',
u'email': u'joe@mail.com',
u'email_verified': u'true',
u'exp': 1363289943,
u'hd': u'google.com',
u'iat': 1363286043,
u'id': u'123456789', # Fake Data
u'iss': u'accounts.google.com',
u'sub': u'123456789', # Fake Data
u'token_hash': u'xxxyyyzzz', # Fake Data
u'verified_email': u'true'}第三部分是前两部分的组合,用谷歌的私钥签名。
https://stackoverflow.com/questions/15410013
复制相似问题