I ve got a Django model thatstarts the Facebook OAuth process:
window.location= https://www.facebook.com/dialog/oauth?client_id=MY_CLIENT_ID&redirect_uri=http%3A//localhost%3A8000/fbpanel/explore-python
接着,在我的达詹戈看来,我收到以下法典:
import cgi
import urllib
# [...]
code = request.GET[ code ]
args = {
client_id : MY_CLIENT_ID,
redirect_uri : http://localhost:8000/fbpanel/explore_python
client_secret : MY_CLIENT_SECRET,
code : code,
}
url = https://graph.facebook.com/oauth/access_token? +
urllib.urlencode(args)
raw_response = urllib.urlopen(url).read()
response = cgi.parse_qs(raw_response)
if response:
error =
if response[ access_token ]:
access_token = response[ access_token ][0]
if response[ expires ]:
expires = response[ expires ][0]
else:
access_token = No access token returned
expires = No expiration given
error = raw_response
Invariably, response
is None
and raw_response
contains Error: {"error":{"message":"Error validating verification code.","type":"OAuthException"}}
I ve manually stepped through the code, printing the code
returned by FB out,
then manually running the above code line by line in the python interpreter, and
I can t see anything I m doing wrong. What are my next debugging steps? The FB
documentation offers little guidance if you receive an OAuthException
.