Google OpenID& OAuth - 如何获取访问令牌

时间:2011-05-08 07:53:20

标签: python oauth access-token google-openid

我有一个网站,我想让用户链接他们的GMail帐户,之后我想通过OAuth访问用户GMail帐户。我使用Google's OpenID+OAuth(混合协议)。

当我按照上面提到的文档时,我得到以下内容 -

openid.assoc_handle AOQobUfg8E9PvTYX1huZPleVGoSvky57TxLHMzI-Lxd87cDNwLyrutSm
openid.claimed_id   https://www.google.com/accounts/o8/id?id=AItOawlus8fqLMQGgfCCM6pDZGpuNjwQqqYMs4o
openid.ext1.mode    fetch_response
openid.ext1.type.email  http://axschema.org/contact/email
openid.ext1.value.email forward@gmail.com
**openid.ext2.request_token   4/C-VqYG9lRtJBKM9G15I-tFk58rOS**
openid.ext2.scope   https://mail.google.com/
openid.identity https://www.google.com/accounts/o8/id?id=AItOawlus8fqLMQGgfCCM6pDZGpuNjwQqqYMs4o
openid.mode id_res
openid.ns   http://specs.openid.net/auth/2.0
openid.ns.ext1  http://openid.net/srv/ax/1.0
openid.ns.ext2  http://specs.openid.net/extensions/oauth/1.0
openid.op_endpoint  https://www.google.com/accounts/o8/ud
openid.response_nonce   2011-05-07T18:38:37ZOEVDbKdW6d2g9A
openid.return_to    https://mysite.com/gmail_redir/
openid.sig  niD5l9V7cG+LOE2zYjJ6rS0Cdwc=
openid.signed   op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle,ns.ext1,ns.ext2,ext1.mode,ext1.type.email,ext1.value.email,ext2.scope,ext2.request_token

我得到 openid.ext2.request_token ,这应该允许我抓取用户GMail acc。通过OAuth。这是如何运作的?我不需要访问令牌(即oauth_access_secret和oauth_access_token)??

我是否还需要提出更多要求?任何人都知道如何继续吗??

1 个答案:

答案 0 :(得分:2)

获得令牌后,您必须

  1. 授权,然后
  2. 将其换成访问令牌
  3. 查看http://code.google.com/apis/accounts/docs/OAuth.html#WorkingOauth

    https://developers.google.com/accounts/docs/OAuth2(适用于OAuth v2)