Authenticating Railway deployment to Google Cloud Platform (GCP)
I have a simple Express server that needs to access one of GCP's client libraries, namely Document AI. Everything works as intended locally, as I successfully load environment variables and authenticate for local development by following this guide: https://cloud.google.com/docs/authentication/provide-credentials-adc#local-dev.
However, when deploying the changes that work locally, my request to the server is stuck in an eternal loading state. I suspect this is because the Railway deployment is not authenticated for GCP Application Default Credentials (https://cloud.google.com/docs/authentication/provide-credentials-adc#how-to).
I have verified that my environment variables are loaded correctly in the production environment, so it must be something else causing the error.
Some relevant documentation I have read through:
- Document AI client libraries: https://cloud.google.com/document-ai/docs/libraries
- How to provide credentials to ADC: https://cloud.google.com/docs/authentication/provide-credentials-adc#how-to
- Authenticate for using client libraries: https://cloud.google.com/docs/authentication/client-libraries
How can I authenticate my Railway deployment for using GCP client libraries?
Google Cloud
Document AI client libraries | Google Cloud
Start writing code for Document AI in C++, C#, Go, Java, Node.js, PHP, Python, Ruby.
5 Replies
Project ID:
c8cf2eaf-d3cc-4e48-a71a-d3d4d26c3b21
c8cf2eaf-d3cc-4e48-a71a-d3d4d26c3b21
How are you providing the credentials in your deployment?
@rayofbytes The thing is: I'm not - I don't know how to do it correctly. Locally, I simply login by running
gcloud auth application-default login
in my terminal. This authenticates my local environment to successfully communicate with GCP.
According to this documentation (https://cloud.google.com/docs/authentication/provide-credentials-adc#on-prem), Google recommends setting the GOOGLE_APPLICATION_CREDENTIALS
environment variable to point to a credential configuration file. However, where should this point to in my Railway deployment? The deployment doesn't know about any credential configuration file.You’ll need to provide your credentials keyfile in the env var. ADC is just a way to provide credentials, look into service accounts for the credentials itself