views:

22

answers:

1

I'm trying to use the Yahoo Social Python SDK to get a users contacts through oAuth. This is for a webapp running on App Engine. SO, I have everything set up to run through the oAuth dance, exchanging consumer keys and verifiers and all that jazz. I store the token and can reuse it to retrieve a users contacts until the token the expires an hour later. So, is there anyone out there who has used the Python SDK and can tell me what is wrong with this simple code:

import yahoo.application
CONSUMER_KEY      = '####'
CONSUMER_SECRET   = '##'
APPLICATION_ID    = '##'
CALLBACK_URL      = '##'
oauthapp      = yahoo.application.OAuthApplication(CONSUMER_KEY, CONSUMER_SECRET, APPLICATION_ID, CALLBACK_URL)
oauthapp.token = yahoo.oauth.AccessToken.from_string(access_token) #access_token is legit string pulled from datastore
oauthapp.token = oauthapp.refresh_access_token(oauthapp.token)
contacts = oauthapp.getContacts()

Running this throws the following error:

'oauth_token'
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/init.py", line 513, in call
handler.post(*groups)
File "/base/data/home/apps/testproj/2.345270664321958961/scripteditor.py", line 1249, in post
oauthapp.token = oauthapp.refresh_access_token(oauthapp.token)
File "/base/data/home/apps/testproj/2.345270664321958961/yahoo/application.py", line 90, in refresh_access_token
self.token = self.client.fetch_access_token(request)
File "/base/data/home/apps/testproj/2.345270664321958961/yahoo/oauth.py", line 165, in fetch_access_token
return AccessToken.from_string(self.connection.getresponse().read().strip())
File "/base/data/home/apps/testproj/2.345270664321958961/yahoo/oauth.py", line 130, in from_string
key = params['oauth_token'][0]
KeyError: 'oauth_token'

Basically, if I comment out the line with refresh_access_token, and the token has not expired, this code works and I get the users contacts. But with refresh_acces_token, it fails at that line. Can anyone give a hand?

A: 

Looks like something wrong with passing params. Try to debug oauth_token variable.

Nazar Leush