user42493
user42493

Reputation: 1113

How to setup properly Google Cloud Shell?

I know this question is probably a bit vague. I was trying to run one of the examples of Google NLP Library in Google Shell.

I have 0 experience with using API, JSON, Nodejs... I don't understand what they are and how to use them.

Please help

Here is the snapshot of the error:

enter image description here

Upvotes: 0

Views: 554

Answers (1)

John Hanley
John Hanley

Reputation: 81454

The error message means that you are using user credentials instead of service account credentials.

When you connect to Google Cloud Shell, you are using your Google Accounts User Credentials. Those credentials are the ones that you used to log in to the Google Cloud Console. When you run an application in Google Cloud Shell, your application is using those credentials unless you explicitly specify different credentials.

The solution is to create a service account in the Google Cloud Console. Then in your program use the service account for credentials for your application.

Google Cloud Service Accounts

When you do not specify the application credentials, the Google Client libraries use a method to locate credentials called ADC (Application Default Credentials). I wrote an article that might help you understand ADC:

Google Cloud Application Default Credentials

The simplest method for you is to create the environment variable GOOGLE_APPLICATION_CREDENTIALS to point to the service account full path location before running your application. Change the path below to point to where the service account is stored on Cloud Shell. You will need to first create the service acount, download it and then upload to Cloud Shell.

export GOOGLE_APPLICATION_CREDENTIALS="$HOME/service-account.json"

Managing files with Cloud Shell

This link will provide more information on how to write applications that use service accounts.

Setting Up Authentication for Server to Server Production Applications

Upvotes: 1

Related Questions