Skip to content
Home ยป Creating a GCP Service Account and linking it to your system

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.

  • Got to this link.
  • If you are developing for Google Cloud Functions, or App Engine, then the App Engine default service account will suffice. Otherwise you will have to create a new account and specify rights for each GCP product.
  • Finally, select JSON.
  • A file should download now. For ease, rename it to ‘creds.json’.
  • Put it in the directory of your development environment.

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.


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


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.

3 thoughts on “Creating a GCP Service Account and linking it to your system”

  1. Pingback: Web scraping with Google Cloud Functions, Pub/Sub, DataFlow & BigQuery — Roel Peters

  2. Pingback: social signals

Leave a Reply

Your email address will not be published. Required fields are marked *