使用 GAE 的服务器端流身份验证失败

发布于 2024-12-09 17:09:20 字数 1706 浏览 0 评论 0原文

我想在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文