使用 GAE 的服务器端流身份验证失败
我想在我的 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,我可以成功获取访问令牌和过期时间!
我真的很困惑。有人可以帮助我吗?
谢谢!我很抱歉我的英语不好。
I want to implement sever side flow authetication on my GAE project.
first, I redirect the user to the OAuth Dialog to get the code.
then I try to authenticate my application with these code(I replace the sensitive part):
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()
and I think I can get access token and expire time in the content variable
but what I got is just error message:
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
it's really odd, because if I print the url variable and link to the url with browser directly, I can get the access token and expire time successfully!
I'm really confused. Can someone help me?
Thanks! and I'm sorry for my poor English.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论