Python 获得';由于401';尝试使用远程api连接时

Python 获得';由于401';尝试使用远程api连接时,python,google-app-engine,google-oauth,Python,Google App Engine,Google Oauth,我正在尝试连接到运行在基于和的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.

我正在尝试连接到运行在基于和的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
和创建一个新的服务帐户,这两个都是建议在这里


你知道我做错了什么吗?

你提到了auth_func2,但没有使用它,根据没有此信息的远程api更新,每次oauth请求时,连接都是不可能的

更改
connect2
方法并尝试以下操作-

@staticmethod
def connect2(project_address):
    remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func2, project_address)
另外,我假设你的
项目地址是正确的,没有“http://”