Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set GOOGLE_APPLICATION_CREDENTIALS for Google Compute Engine?

I have Google Compute Engine's Credentials file , renamed as key.json. The next step is to set the environment variable with name GOOGLE_APPLICATION_CREDENTIALS. But it says error: Error reading credential file from environment variable GOOGLE_APPLICATION_CREDENTIALS ...path.. Error reading credentials from stream, 'type' field not specified.

httpTransport = GoogleNetHttpTransport.newTrustedTransport(); GoogleCredential credential = GoogleCredential.getApplicationDefault();

I want to know how to set variable GOOGLE_APPLICATION_CREDENTIALS in eclipse?

like image 378
Aakash Parashar Avatar asked Feb 25 '16 14:02

Aakash Parashar


People also ask

How do I authenticate with Google Cloud Storage?

API authenticationIn the OAuth 2.0 Playground, click Cloud Storage API v1, and then select an access level for your application ( full_control , read_only , or read_write ). Click Authorize APIs. Sign in to your Google account when prompted. In the dialogue that appears, click Allow.


1 Answers

You got the error because you downloaded an OAuth 2.0 Client ID instead of a Service Account key.

If you want to use regular user credentials as the application default, you can now use the gcloud beta auth application-default login command to launch the web sign-in flow. This puts them in the well-known location for application default credentials, so you should unset the GOOGLE_APPLICATION_CREDENTIALS variable if you use this method.

like image 115
Adam Avatar answered Sep 17 '22 23:09

Adam