DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 966,904 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Alexander Oloo
Alexander Oloo

Posted on • Originally published at alexanderoloo.com on

Loading Google Credentials without .json

I primarily use heroku to run my applications and Travis for CI/CD. Iโ€™m also currently giving Github Actions a try. So what do all those have in common? Well, for starters they have generous free tiers, but more importantly theyโ€™re not in the Google Cloud. Google cloud has some really nifty capabilities and so I end up using them pretty often. Thatโ€™s where my problem started.

When you want to authenticate your application from outside the Google Cloud you need to read in a .json file that contains the service account information.

File credentialsPath = new File("/home/user/Downloads/[FILE_NAME].json");  

or

export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/[FILE_NAME].json"

So we basically need to get this .json file into all our CI/CD pipelines and our application servers. Obviously we canโ€™t store the credentials in git so we need to encrypt and upload the file. Admin!

alekcz/google-credentials solves exactly this problem. Your clojure app can now load credentials from an environment variable using alekcz/google-credentials.You need not keep that super secret .json file anymore. Copy its contents into the environment and delete the file!

And there you go. Nothing but net.

Kobe!

May your build always pass.

Alex

P.S. Rest in peace Kobe.

Top comments (0)

๐ŸŒš Life is too short to browse without dark mode