我正在尝试连接到基于 Google App Engine 的生产数据存储https://cloud.google.com/appengine/docs/python/tools/remoteapi#enabling_remote_api_access_in_your_app https://cloud.google.com/appengine/docs/python/tools/remoteapi#enabling_remote_api_access_in_your_app and AppEngine - 远程 API 返回 401 和过多身份验证 https://stackoverflow.com/questions/33378616/appengine-remote-api-returning-401-and-too-many-auth and GAE:remote_api 和应用程序默认凭据 https://stackoverflow.com/questions/32567357/gae-remote-api-and-application-default-credentials和别的。
这是我连接到 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 ('[email protected] /cdn-cgi/l/email-protection','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 - 远程 API 返回 401 和过多身份验证 https://stackoverflow.com/questions/33378616/appengine-remote-api-returning-401-and-too-many-auth
有什么想法我做错了吗?