Getting "Update from 401" when trying to connect using remote_api

I am trying to connect to a production repository running on Google App Engine based on https://cloud.google.com/appengine/docs/python/tools/remoteapi#enabling_remote_api_access_in_your_app and AppEngine - a remote API that returns 401 and too-much auth and GAE: remote_api and application default credentials and others.

This is my code for connecting to the Google App Engine datastore

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)

But I get an error

NotSupportedOnThisPlatform

If I then installed

secure=False

Then i get

 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

I tried to run

gcloud auth login

and creating a new service account, which is offered here by AppEngine - a remote API that returns 401 and too-much-aut

, ?

+4
1

auth_func2, , remote_api oauth, .

connect2 -

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

P.S - , project_address 'http://'

0

Source: https://habr.com/ru/post/1656481/


All Articles