C
C#•2w ago
bliko

Google credentials.json & token.json in environment variables? Or in render? Or where?

Hey everyone, I'm a front end developer and I'm dipping my toes into .NET helping out in an internal tool for my company. Right now the App is based on React/Vite/TS and the back is .NET 8. I'm currently working on a Proof of Concept inside of the internal App that consist of: Gmail Service / Gmail Controller: The user logins, and gets an array of their unread emails (Then I process it someway and they get it displayed in the internal tool in a notifications badge.) The issue that I'm facing is that in order to use the Gmail API I created a credentials.json to work locally, and when validating in the service it creates a token.json. My question is what should I do with the credentials.json? I thought of using it as an env variable but I can't straight up put a JSON object, and the option that I'm left with is like stringifying the json, and then deserialize and build like a JSON on the service which is a complete mess...I'm kinda lost and I haven't found much information.of which is the best way. The project is hosted on render, I thought of maybe puting the credentials.json in there somehow? (I don't have access to Render, it's managed by the TL.)
4 Replies
Harbour
Harbour•2w ago
Could you extract some of the values from this json into an appsettings.json - don't deploy these secrets and build a pipeline to insert the secret values?
Arjix
Arjix•2w ago
one shitty solution would be to have the path to the json as the env var (assuming you have access to the files on the server) and if the env var is not declared, or it doesn't point to a valid file, then force close the backend and print an error message (in case you don't find a better solution)
bliko
blikoOP•2w ago
thanks both @Arjix and @Harbour I'll take a look at this tomorrow and let you know what works.
Harbour
Harbour•2w ago
np; just remember not to commit the secrets on a public repo 😂

Did you find this page helpful?