David Alonso
David Alonso6mo ago

Uploading service account file for authentication

My code needs to communicate with Google Cloud Services and I need to store this env variable: GOOGLE_APPLICATION_CREDENTIALS which contains a path to a service account file. My question is what I should set this path to and where I should put this service account file inside the convex local folder for it to be uploaded if that's even possible?
13 Replies
jamwt
jamwt6mo ago
any reason you don't just want to put the creds directly into the environment variable?
David Alonso
David AlonsoOP6mo ago
Only reason being that idk if GCLOUD supports that
jamwt
jamwt6mo ago
GitHub
GitHub - googleapis/google-auth-library-nodejs: 🔑 Google Auth Libra...
🔑 Google Auth Library for Node.js. Contribute to googleapis/google-auth-library-nodejs development by creating an account on GitHub.
David Alonso
David AlonsoOP6mo ago
From my Firebase AI Monitoring POC: hmmm yeah, that's hidden behind our plugin which is wrapping the google cloud opentelemetry plugin. The layers of abstraction are getting in the way of the vanilla case here. so I'm wondering if we can read write from/to the deployed file system
David Alonso
David AlonsoOP6mo ago
seems like trying to do a hack of writing to the convex fs doesn't work
No description
ian
ian6mo ago
You can import from a .json file, but I suspect doing npx convex env set GOOGLE_APPLICATION_CREDENTIALS <value> is easier?
David Alonso
David AlonsoOP6mo ago
Right, but the problem is that the google product I’m using expects that env variable to be a path to a json file, not the json file or value itself (i know this is super annoying) Basically, is there any way to control the convex FS?
ian
ian6mo ago
I don’t think so- writes definitely aren’t allowed. You can use the debug flags on convex dev to see the paths to files that are uploaded if you want to play around with that to see if the json file would get preserved to get a relative path. But you might need to dig around in the Gemini plugin code to get the value plumbed through another way / as an explicit runtime parameter
erquhart
erquhart6mo ago
I know I've used Google account credentials inlined into an env var, and I remember having to dig to find out how in their docs, because they apparently don't want you doing that. But I don't know if it's possible across their products. It's been some years, so unfortunately I don't have anything more helpful than that. I believe the python sdk explicitly provides a load method, I don't know why the node one does not. Google's SDK's are pure pain.
David Alonso
David AlonsoOP6mo ago
Yep ^ 😩 we're running into this issue now with the Google team: You can add up to 100 environment variables. Environment variable names cannot be more than 40 characters long, and they must start with a letter and only contain letters numbers, and underscores. Environment variable values cannot be larger than 8KB.
erquhart
erquhart6mo ago
40 characters, woof
David Alonso
David AlonsoOP6mo ago
i guess that's for the name of the env variable? then it should be fine
erquhart
erquhart6mo ago
ooohh gotcha

Did you find this page helpful?