问题
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