-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PubSub] Use environment variables instead of file for private key? #761
Comments
You can provide a credentials object with the contents of your key file. So you can set env vars for each property in your key file, then pass them like you did in your snippet above, except embedded in a credentials object. More on the ways we support auth: https://googlecloudplatform.github.io/gcloud-node/#/authorization Let me know if this works! |
I see, so I can do something like:
Thanks! |
Yep! Sorry for the lack of a code example earlier, that's exactly right :) |
I'm getting a
when I try to use the code snippet I commented with earlier. I tried setting the environment variable PRIVATE_KEY with and without the "BEGIN PRIVATE KEY..." markers. I don't get this error if I use (Sorry, my previous comment got deleted accidentally). |
Should I raise another issue for this? I'd like if someone could attempt to replicate the bug first, to see if it's not just something I'm messing up/is unclear in the documentation. |
I just tried and failed to replicate when using the exact values from my keyfile.json. I did get the error when I changed a single character from the opening and closing markers. So, be sure it's exactly the format that is in the JSON:
|
Hmm I'm trying the following:
I tried generating a new keyfile.json file as well, and using the new private key; still didn't work. Note that I get the error when creating a topic:
Also, the keyfile is for a service account; don't know if that is relevant. |
I am doing the same thing and running on an AWS instance. However, the error I get is Error: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information. What am I doing wrong? PS: I am trying to get an existent topic. |
@ShivanKaul sorry that I forgot to respond to your last comment. I hope you found a solution. If not, please re-open so we can figure it out. @eduardo-tenorio-guiabolso I wonder if that's a new bug. Could you open a new issue? I'll take a look at it tomorrow. |
OK. |
@stephenplusplus here it is: #1173 |
Thank you!!! Have been looking for this solution for so long! |
Thanks a lot! |
For anyone looking at this issue in the future, here is an updated link to the documentation: |
The sample code on the README asks me to specify a path to a file:
I wanted to use Heroku to run my server, and a GitHub public repo for source control, and the canonical way to handle secrets with Heroku is through setting config vars. It's extremely annoying to check a file into Heroku but not GitHub.
Shouldn't there be some way of specifying secrets individually, i.e. something like:
The text was updated successfully, but these errors were encountered: