我在這裏找到了方向如下:Facebook的OAuth的問題
http://developers.facebook.com/docs/authentication/
試圖連接到Facebook的圖形API服務器端。我使用Django和基本複製相同的代碼在這裏找到:
https://github.com/facebook/python-sdk/blob/master/examples/oauth/facebookoauth.py
這裏是我的代碼
def get_code(request):
c = RequestContext(request)
verification_code = request.GET.get('code',None)
args = dict(client_id=FACEBOOK_APP_ID, redirect_uri=REDIRECT)
if verification_code:
args["client_secret"] = FACEBOOK_SECRET_KEY
args["code"] = verification_code
response = cgi.parse_qs(urllib.urlopen(
"https://graph.facebook.com/oauth/access_token?" +
urllib.urlencode(args)).read())
print "------------------------"
print response
#access_token = response["access_token"][-1]
#print access_token
print "------------------------"
else:
http.HttpResponseRedirect("https://graph.facebook.com/oauth/authorize?" + urllib.urlencode(args))
不管怎麼說,我能順利拿到授權代碼,但是當我嘗試用它來獲得我的access_token,我看到以下響應:
{
"error": {
"type": "OAuthException",
"message": "Error validating verification code."
}
}
我不知道是怎麼回事,但我對兩者是叔以下幾個方向是他的臉書網站,以及他們提供的代碼,這不適用於Python或瀏覽器。有趣的是,如果我使用具有相同憑證的客戶端流程,我可以通過散列標籤獲取access_token,但這對我沒有用處。
此外,我正在測試本地@http://127.0.0.1:8000,並通過我的Facebook應用程序設置正確配置。
由於
UPDATE:
我固定它,事實證明這兩種redirect_urs必須是相同的 我使用
^/實/ AUTH/
和
^facebook/auth/token/
,只要我使用這兩種
的Facebook /認證/ + Facebook的/ auth /中
它的工作
絕對將您的修補程序拆分爲答案,並將其標記爲已接受。我保證,你遇到的問題已經讓其他人感到困擾。 – tephyr