Reputation:
I am new to Google Cloud Platform.
Now, i need to connect the node server running on my local machine to Google Cloud Datastore using the service account key. How can i do this? I got a bit confused with lot of documentations posted on Google cloud site. Can someone please explain me the steps/process/flow ?
Upvotes: 0
Views: 484
Reputation: 437
You can connect to a remote google datastore from your local node app via the Google Service Key API: https://cloud.google.com/docs/authentication/getting-started#linux-or-macos
The process is simple enough:
Mac/Linux (via command line)
export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/my-key.json"
Windows (via powershell)
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\Users\username\Downloads\my-key.json"
You can generate this Google Service Key by clicking this link: https://console.cloud.google.com/apis/credentials/serviceaccountkey?_ga=fuckuranalytics
Upvotes: 0
Reputation: 5506
Google Cloud Datastore has a local development server that you can use: https://developers.google.com/datastore/docs/tools/devserver
You can create and start the local datastore using the gcd tool which is linked to in the doc above.
If you use DatastoreHelper.getDatastoreFromEnv();
to build your Datastore, you can tell it to connect to your local database by exporting the env variable DATASTORE_HOST:
export DATASTORE_HOST=http://localhost:8080
Upvotes: 1