我想在我的GAE项目上实现服务器端流认证。
首先,我将用户重定向到OAuth对话框以获取代码。
然后我尝试用这些代码验证我的应用程序(我替换敏感部分):
code = self.request.get('code')
url = 'https://graph.facebook.com/oauth/access_token?client_id=00000000000000&redirect_uri=http://000000000000.com/&client_secret=00000000&code=' + code
response = urllib2.urlopen(url)
content = response.read()
我认为我可以在内容变量中获取访问令牌和过期时间
但我得到的只是错误信息:
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 701, in __call__
handler.get(*groups)
File "/base/data/home/apps/s~livingtomato/1.353914368655529058/main.py", line 28, in get
response = urllib2.urlopen(url)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 124, in urlopen
return _opener.open(url, data)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 387, in open
response = meth(req, response)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 498, in http_response
'http', request, response, code, msg, hdrs)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 425, in error
return self._call_chain(*args)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 360, in _call_chain
result = func(*args)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 506, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 404: Not Found
这真的很奇怪,因为如果我打印url变量并直接通过浏览器链接到url,我可以成功获取访问令牌和到期时间!
我真的很困惑。有人能帮助我吗?
谢谢!对不起我的英语很差。