If you are on GCP and deploying app engine services with google datastore as your database, you will often need ways look in datastore apart from google console. The reason being, you may require to put multiple filters fetching data which is not possible through google console beyond certain limited way.
Solution
Remote API is the solution. You can connect to real app services such as datastore using google cloud sdk locally.
- As the first step, you will have to enable remote API within your application configuration app.yaml. Google documentation explains it well.
- Next, navigate to the directory where google cloud sdk is installed.
3. Command to connect to datastore is as follows –
sudo python remote_api_shell.py -s <PROJECT_ID>.appspot.com
# inside remote API console from google.appengine.ext import vendor vendor.add('lib')
# Usage: # Launch the Remote API eg through: python /Users/<user-name>/google-cloud-sdk/platform/google_appengine/remote_api_shell.py -s <PROJECT_ID>.appspot.com
# Fix the imported libs import appengine_config from google.appengine.ext import vendor vendor.add('lib') import sys sys.modules.pop('pyasn1_modules')
Use `gcloud auth application-default login`
`gcloud auth application-default` command allows you to manage active credentials on your local machine.
[/Users/<username>/.config/gcloud/application_default_credentials.json]
File "/Users/<user_name>/projectlib/lib/google/auth/crypt/__init__.py", line 38, in <module> from google.auth.crypt import base ImportError: cannot import name base
cloud auth application-default login restores your default authentication credentials but if you want to login to the application as user, you have to use below command –
gcloud auth login # logs you in as user.