Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine Remote API + OAuth

I'm using GAE remote api to access the data store of my app. The authentication to GAE is made using remote_api_stub.ConfigureRemoteApi with an authentication function that returns a user name and a password.

Is there a way for authenticating using an access_token, for example OAuth or OAuth 2.0?

like image 420
Tzach Avatar asked Oct 22 '22 04:10

Tzach


1 Answers

There is a solution for Google accounts configured to use 2-Step Verification.

At the moment, you are probably seeing a “BadAuthentication InvalidSecondFactor" error thrown, as you are not able to properly login from the shell.

In order to solve this, you will need an App Password that authorizes the app to access your account resources. Follow the tutorial and use the generated password and the username of an admin of the target App Engine app as the credentials for Remote API.

UPDATE:

Additionally, you can take a look at the remote_api_stub.py file from the AppEngine SDK. You'll find a family of methods called _ConfigureRemoteApiWith* (note the leading underscore), such as:

  • _ConfigureRemoteApiWithKeyFile
  • _ConfigureRemoteApiWithComputeEngineCredential
  • _ConfigureRemoteApiWithOAuthCredentials

Methods themselves are well documented, please take a look at their docstrings. They'll let you authenticate with safer methods than usual ASP provided by remote_api_stub.ConfigureRemoteApi().

like image 137
cjlallana Avatar answered Oct 27 '22 10:10

cjlallana