对象中检索令牌和秘密

对象中检索令牌和秘密

本文介绍了从 gdata.gauth.OAuthHmacToken python 对象中检索令牌和秘密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 Google 很棒的示例代码用于三足式 OAuth.

I'm following Google's great sample code for three-legged OAuth.

具体来说,我正在查看代码的 python 版本.我被困在升级到访问令牌"和使用访问令牌"之间.

Specifically, I'm looking at the python version of the code. I'm stuck between 'Upgrading to an access token' and 'Using an access token'.

在升级到访问令牌"中,有一行代码如下:

In 'Upgrading to an access token', there is a line of code as follows:

access_token = client.GetAccessToken(request_token)

在使用访问令牌"中,有一行代码如下:

In 'Using an access token', there is a line of code as follows:

client.auth_token = gdata.gauth.OAuthHmacToken(CONSUMER_KEY,
                                               CONSUMER_SECRET,
                                               TOKEN,
                                               TOKEN_SECRET,
                                               gdata.gauth.ACCESS_TOKEN)

我假设 TOKENTOKEN_SECRET 被打包到 access_token 对象(gdata.gauth.OAuthHmacToken)中,但我如何检索它们?

I assume TOKEN and TOKEN_SECRET are packed into the access_token object (gdata.gauth.OAuthHmacToken), but how do I retrieve them?

谢谢!

推荐答案

我能够解决这个问题.

access_token 属于 gdata.gauth.OAuthHmacToken 类型.因此,与其尝试传递单个参数,不如这样做:

access_token is of type gdata.gauth.OAuthHmacToken. So instead of trying to pass in the individual arguments, I could just do this:

client.auth_token = access_token

这篇关于从 gdata.gauth.OAuthHmacToken python 对象中检索令牌和秘密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 20:02