Rather than storing a credentials file on the server, we opted to use env vars to store the required info:
GOOGLE_CLIENT_ID
GOOGLE_CLIENT_EMAIL
GOOGLE_ACCOUNT_TYPE
GOOGLE_PRIVATE_KEY
And we're obtaining authorization for a CalendarService as follows:
scopes = ["https://www.googleapis.com/auth/calendar"]
auth = ::Google::Auth.new_application_credentials(scopes)
service = ::Google::Apis::CalendarV3::CalendarService.new
service.authorization = auth
service.authorization.fetch_access_token!
Every part of the process works locally - authorizing, fetching an access token, interacting with API, etc. When we deploy to our staging environment on Heroku, we can't get past the following error:
Unable to read the credential file specified by GOOGLE_APPLICATION_CREDENTIALS: Neither PUB key nor PRIV key: nested asn1 error
I had seen this error in testing so I know it can be related either to a missing credentials file (like the error indicates) OR to an invalid id, private key, or email combination (because I was accidentally replacing the private key with an invalid value). In that situation, the error message was identical.
We have verified that all vars match the credentials used locally - what am I missing?