Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download the default service account .json key

I have a google console account, but when I got to the service account section, I saw something
like this:
enter image description here

So there are a lot of service accounts I see for my project, and there is a Key ID along
with them also there. When I am running my Java code on my local machine, I get the error:

Exception in thread "main" java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

For this, I saw a resolution like :

Go to Google Developers Console -> Credentials and create a default service account .json key. It will download a file like default-account-credentials.json for you when you do that.

The above step mentions that I will need to create a default service account, and then it
will automatically download the .json credentials key. Is it possible to download the
.json key for the service account already listed on the service accounts page
on google cloud?
I see the Key ID, but I am not sure if that is the same as the .json key
file downloaded when a new service account is created.

like image 252
dnaiel Avatar asked Oct 23 '25 11:10

dnaiel


1 Answers

Existing .json keys cannot be downloaded after creation. They can only be downloaded when they are created.

Your best option would be to create a new key and for security reasons, delete the old key if not needed to avoid any potential threats regarding the old key.

To do so, go to IAM->Service Account, then select your service account and access the "Key" tab. In this tab you will see the existing key(s) and will have the option to create a new one.

like image 126
someRandomDev Avatar answered Oct 25 '25 07:10

someRandomDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!