1

To make a server-server interact with a Google API in development I need to put my service-account JSON key in the root of myapp, set

ENV["GOOGLE_APPLICATION_CREDENTIALS"] = "api-test-key.json" 

and all is good.

But in production on Heroku there are config vars and the google_auth credentials_loader.rb insists on a file.

I managed to put the JSON's contents in a heroku config var nicely and can get it by calling

puts ENV["GOOGLE_APPLICATION_CREDENTIALS"]

What to do?

There is this question where they figured out a workaround but that is for oauth2 not for service-account type JSON:

How to upload a json file with secret keys to Heroku

asked Jul 19, 2016 at 15:10

1 Answer 1

0

We config our GoogleAPI credentials via the application.yml file ... found in the root/config/application.yml file.

In it we have;

AUTH_URI: https://accounts.google.com/o/oauth2/auth
CLIENT_SECRET: xxxxxxx
TOKEN_URI: https://accounts.google.com/o/oauth2/token
CLIENT_EMAIL: xxxx
REDIRECT_URIS: http://localhost:3000/signin/connect
CLIENT_X509_CERT_URL: https://www.googleapis.com/robot/v1/metadata/x509/901506026811-q0am03i585627ptu5r38o7cpkt8pk98l@developer.gserviceaccount.com
CLIENT_ID: xxx
AUTH_PROVIDER_X509_CERT_URL: https://www.googleapis.com/oauth2/v1/certs
JAVASCRIPT_ORIGINS: http://localhost:3000
PLUS_LOGIN_SCOPE: https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/plus.circles.read

You could maybe load in your config settings here?

answered Jul 20, 2016 at 10:14
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks but it is for oauth2. BTW is it checked in to version control?
Yes it is - you're right most people keep such a file on .gitignore ... as loaded in separately. Maybe you have no file in version control?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.