Site icon Roel Peters

Creating a GCP Service Account and linking it to your system

When you haven’t gone through the Google Cloud Platform authentication process in your development environment, you might run into the following error message. In this blog post, I explain how you can solve it.

google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application.

Basically, the Cloud SDK is telling you that it’s not able to tell who you are when you are trying to access some GCP products. For this, we will create service account credentials and link them to your machine.

Finally, you should add the path to this file as an environment variable to your system.

PowerShell offers the following easy method to set the environment. If you want to variable to persist, you should read up on this article.

$Env:GOOGLE_APPLICATION_CREDENTIALS='x:\xxxxx\xxx.json'

In the Windows Command Prompt you can do it as follows. You can replace set with setx to make it a persisting environment variable.

set GOOGLE_APPLICATION_CREDENTIALS "x:\xxxxx\xxx.json"

In UNIX systems, you use the export command. To make it persisting, read this detailed thread about the ways you can set environment variables.

export GOOGLE_APPLICATION_CREDENTIALS="x:\xxxxx\xxx.json"

Great success!

Say thanks, ask questions or give feedback

Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.

Exit mobile version