Hello Everyone,
I am trying to connect to Yahoo's OAuth server using App Engine and i keep getting an error msg:
(I got this by redirecting the request to my our server and dumping the header/contents)
HEADER
{'date': 'Tue, 21 Apr 2009 05:00:17 GMT', 'transfer-encoding': 'chunked', 'cache-control': 'no-cache', 'content-type': 'text/html; charset=utf-8', 'server': 'Google Frontend'}
CONTENT
oauth_nonce=87287779&oauth_timestamp=1240290017&oauth_consumer_key=MYCONSUMERKEY&
oauth_signature_method=plaintext&oauth_version=1.0&oauth_signature=MYSECRETCODE%26
&xoauth_lang_pref=en-us
When I connect to the auth server using the above data, I get this msg:
{'Via': 'HTTP/1.1 GWA', 'X-Google-Cache-Control': 'remote-fetch', 'Connection': 'close', 'Date': 'Tue, 21 Apr 2009 05:12:19 GMT', 'P3P': 'policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"', 'Content-Type': 'application/x-www-form-urlencoded', 'WWW-Authenticate': 'OAuth oauth_problem=consumer_key_rejected'}oauth_problem=consumer_key_rejected
OAuth error codes suggest that consumer_key_rejected means the app is disabled. So I regenerate the key and I still have the same issue.
I tried this from my app engine (production) account (verified domain) and also from my test server. Same issue....
Could you please let me know what I am doing wrong? I am posting the basic code below:
def generate_timestamp(self):
return int(time.time())
def generate_nonce(self,length=8):
return ''.join([str(random.randint(0, 9)) for i in range(length)])
def get(self):
#includes the additional & because i am using plaintext
req_token = {
'oauth_nonce': self.generate_nonce(),
'oauth_timestamp': self.generate_timestamp(),
'oauth_consumer_key':'MYCONSUMERKEY',
'oauth_signature_method':'plaintext',
'oauth_signature':'MYSECRET&',
'oauth_version':'1.0'
}
req_token_enc = urllib.urlencode(req_token)
# URL Fetch documentation is here:
# http://code.google.com/appengine/docs/python/urlfetch/overview.html
result = urlfetch.fetch(url="https://api.login.yahoo.com/oauth/v2/get_request_token",
payload=req_token_enc,
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-form-urlencoded'})
if (result.status_code == 200):
self.response.out.write(result.headers)
self.response.out.write(result.content)
else:
self.response.out.write("ERROR\n\n")
self.response.out.write(result.headers)
self.response.out.write(result.content)