标签:python google-app-engine google-oauth2
我正在尝试连接到基于https://cloud.google.com/appengine/docs/python/tools/remoteapi#enabling_remote_api_access_in_your_app和AppEngine – Remote API returning 401 and too-many-auth以及GAE: remote_api and Application Default Credentials等在Google App Engine上运行的生产数据存储区.
这是我连接到Google App Engine数据存储区的代码
try:
import dev_appserver
dev_appserver.fix_sys_path()
except ImportError:
print('Please make sure the App Engine SDK is in your PYTHONPATH.')
raise
from google.appengine.ext.remote_api import remote_api_stub
import os
class RemoteApi:
@staticmethod
def use_remote_datastore():
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = "my-appengine-default-service-account.json"
project_id = 'myapp'
project_address = '{}.appspot.com'.format(project_id)
RemoteApi.connect2(project_address)
@staticmethod
def auth_func2():
return ('myuser@myemail.com','mypassword')
@staticmethod
def connect2(project_address):
remote_api_stub.ConfigureRemoteApiForOAuth(
project_address,
'/_ah/remote_api', secure=True)
但是我收到了错误
NotSupportedOnThisPlatform
如果我然后设置
secure=False
然后我得到了
INFO 2016-10-01 23:35:32,727 client.py:546] Attempting refresh to obtain initial access_token
....
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/dummy_thread.py", line 73, in allocate_lock
return LockType()
RuntimeError: maximum recursion depth exceeded
我试过跑步
gcloud auth login
并创建一个新的服务帐户,这些都在这里建议AppEngine – Remote API returning 401 and too-many-auth
我有什么想法我做错了吗?
解决方法:
您已经提到了auth_func2但没有使用它,根据每次使用oauth请求时没有此信息的remote_api更新,无法建立连接.
更改你的connect2方法,试试这个 –
@staticmethod
def connect2(project_address):
remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func2, project_address)
P.S – 我假设你的project_address是正确的,没有’http://’
标签:python,google-app-engine,google-oauth2 来源: https://codeday.me/bug/20190711/1429669.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。