How to upload Google service account credentials (JSON file) to a volume?
evanht
PROOP

2 years ago

Hi,

I need to upload my Google service account json to a volume attached to my service, but I can't seem to find a way to do that. I don't see a command in the CLI or any way to do it from the UI. What do you recommend?

Thanks

Solved

2 Replies

2 years ago

I would recommend placing the contents of the JSON file inside a service variable, and reading from it from inside your app.


Status changed to Awaiting User Response Railway over 1 year ago


1beb
PRO

a year ago

Some extra commentary here, because I spent a few hours going through local > deployment loop to figure this out:

```
credentials = service_account.Credentials.from_service_account_info(

json.loads(os.environ.get("GOOGLE_APPLICATION_CREDENTIALS_JSON"))

)

opts = ClientOptions(api_endpoint=f"...")

client = something.yourClient(client_options=opts, credentials=credentials)
```

The JSON needs to be formatted without linebreaks as a single line, the linebreak characters inside of the private_key, don't touch those. But it should be all on the same line, with no external quotes when you paste it into railway. The string you paste into the GOOGLE_APPLICATION_CREDENTIALS_JSON variable should be like:

```
{"type":"service_account", "project_id":"your-project-id",...}
```
No outside quotes!


Status changed to Awaiting Railway Response Railway about 1 year ago


Status changed to Solved brody about 1 year ago


Loading...