2016-10-01 2 views
4

Ich versuche, eine Verbindung zum Produktionsdatenspeicher auf Google App Engine basierend auf https://cloud.google.com/appengine/docs/python/tools/remoteapi#enabling_remote_api_access_in_your_app und AppEngine - Remote API returning 401 and too-many-auth und GAE: remote_api and Application Default Credentials und anderen herzustellen.Getting 'Refreshing for a 401' beim Versuch, eine Verbindung über remote_api herzustellen

Dies ist mein Code zu Google App Engine-Datenspeicher

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]','mypassword') 

    @staticmethod 
    def connect2(project_address): 
      remote_api_stub.ConfigureRemoteApiForOAuth(
      project_address, 
      '/_ah/remote_api', secure=True) 

Aber ich erhalte den Fehler

NotSupportedOnThisPlatform 

Wenn ich gesetzt

secure=False 

ich dann

dann zu verbinden bekommen
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 

versuchte ich

gcloud auth login 

ausgeführt wird und ein neues Dienstkonto zu schaffen, die sowohl Irgendwelche Ideen AppEngine - Remote API returning 401 and too-many-auth

hier vorgeschlagen werden, was ich falsch mache?

Antwort

0

Sie haben auth_func2 erwähnt, aber es nicht verwendet, nach remote_api Updates ohne diese Informationen jedes Mal mit der oauth Anfrage, eine Verbindung ist nicht möglich. Diese

Ihre connect2 Methode ändern und versuchen -

@staticmethod 
def connect2(project_address): 
    remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func2, project_address) 

P. S - Ich gehe davon aus Ihrer project_address ist richtig und ohne 'http: //'

Verwandte Themen