gpt4 book ai didi

django - 在 OAuth2.0 dance 中找不到服务 "memcache"的 api 代理

转载 作者:行者123 更新时间:2023-12-01 21:26:38 33 4
gpt4 key购买 nike

我尝试在我的应用程序中实现 OAuth2.0,但遇到了问题,但现在无法修复。

错误是:

Traceback:
File "/home/i159/Envs/photorulez/lib/python2.6/site- packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/home/i159/workspace/photorulez/photorulez/photoapp/views.py" in get_token
63. saved_token = gdata.gauth.AeLoad(request.GET.get('oauth_token'))
File "/home/i159/Envs/photorulez/lib/python2.6/site-packages/gdata/gauth.py" in ae_load
1289. token_string = gdata.alt.app_engine.get_token(key_name)
File "/home/i159/Envs/photorulez/lib/python2.6/site-packages/gdata/alt/app_engine.py" in get_token
51. token_string = memcache.get(unique_key)
File "/home/i159/Envs/photorulez/lib/python2.6/site- packages/google/appengine/api/memcache/__init__.py" in get
487. self._make_sync_call('memcache', 'Get', request, response)
File "/home/i159/Envs/photorulez/lib/python2.6/site-packages/google/appengine/api/apiproxy_stub_map.py" in MakeSyncCall
94. return stubmap.MakeSyncCall(service, call, request, response)
File "/home/i159/Envs/photorulez/lib/python2.6/site-packages/google/appengine/api/apiproxy_stub_map.py" in MakeSyncCall
301. assert stub, 'No api proxy found for service "%s"' % service

Exception Type: AssertionError at /get_access_token/
Exception Value: No api proxy found for service "memcache"

代码是:

CONSUMER_KEY = 'anonymous'
CONSUMER_SECRET = 'anonymous'
SCOPES = ['https://picasaweb.google.com/data/',]

def oauth2_login(request):
client = gdata.docs.client.DocsClient(source='photorulez')

oauth_callback_url = 'http://%s/get_access_token' % '127.0.0.1:8000'

request_token = client.GetOAuthToken(
SCOPES,
oauth_callback_url,
CONSUMER_KEY,
consumer_secret=CONSUMER_SECRET)

request.session['request_token'] = request_token
return HttpResponseRedirect(request_token.generate_authorization_url())


def get_token(request):
client = gdata.docs.client.DocsClient(source='photorulez')
saved_token = gdata.gauth.AeLoad(request.GET.get('oauth_token'))
uri = 'http://127.0.0.1:8000'

request_token = gdata.gauth.AuthorizeRequestToken(
saved_token,
uri)
access_token = client.GetAccessToken(request_token)

client.auth_token = gdata.gauth.OAuthHmacToken(CONSUMER_KEY,
CONSUMER_SECRET,
access_token.token,
access_token.token_secret,
gdata.gauth.ACCESS_TOKEN)
return HttpResponseRedirect('/')

我刚刚通过 pip 安装了 google_appengine-1.5.1 模块,我的应用程序在 Django 开发服务器上运行。我能做什么来修复它?我应该只在 GAE 上运行它吗?

最佳答案

看来您需要运行 GAE,因为 OAth 实现使用 GAE 内存缓存服务。您告诉 GAE API 您的 Django 服务器将处理 GAE 调用。您可能需要运行 GAE 开发服务器,以便它可以处理请求。

如果您不想运行 GAE 服务器,则看起来像 this blog entry显示了运行足够的 GAE 来服务此请求的代码。

关于django - 在 OAuth2.0 dance 中找不到服务 "memcache"的 api 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7778263/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com