Retrieving token and secret from gdata.gauth.OAuthHmacToken python object

余生长醉 提交于 2019-12-22 08:44:45

问题


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

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)

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

Thanks!


回答1:


I was able to figure this out.

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


来源:https://stackoverflow.com/questions/5569074/retrieving-token-and-secret-from-gdata-gauth-oauthhmactoken-python-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!