Skip to content
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

keyFilename requires .json extension if credentials file is of JSON type - docs #1717

Closed
simonfan opened this issue Oct 18, 2016 · 3 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@simonfan
Copy link
Contributor

When using keyFilename upon initialization to specify the filename of JSON credentials, the .json extension seems to be required, otherwise the file will be interpreted as of another format.

My use case was when storing the gcp-keyfile.json in a Kubernetes secret:

apiVersion: v1
kind: Secret
metadata:
  name: some-secret
type: Opaque
data:
  # will be available as a file /path/to/secret/gcp-keyfile
  gcp-keyfile: d2hhdGV2ZXIK...

When using that keyFilename, an error would be thrown: Error: could not authorize request email is required, because google-cloud did not recognize the key as being of JSON type (I guess). Is that right?

The only way of solving the problem was to change the gcp-keyfile to gcp-keyfile.json

Now that I've solved my issues with that it seems quite intuitive (almost obvious I'd say) that the .json extension is important, but I've wasted some hours not understanding why the error was happening.

I think it might be important to make this clearer in the documentation in some way (I'd make a pr but do not understand the auth process so well..)

Might be related to #768

@stephenplusplus
Copy link
Contributor

I can completely sympathize with spending a lot of time on an issue, only to realize it was something simple. I'm sorry you had to go through that, but I'm glad everything is working properly now! I went to our docs and saw that we say "config.keyFilename - string - Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console." If you can find a way to improve our docs, or if someone else sees this and went through the same, please send us a PR!

@stephenplusplus stephenplusplus added type: question Request for information or clarification. Not an issue. auth labels Oct 18, 2016
@onbjerg
Copy link

onbjerg commented Jan 29, 2017

I'm so glad this issue existed, it just saved me more hours of debugging. This is exactly the same issue I had, and the fix was to add the JSON filename extension.

Still seems very unintuitive.

@rexxars
Copy link

rexxars commented Oct 9, 2017

I ran into the same thing just now. While I appreciate the addition to the documentation, the README is what I usually consult for a quick reference, and it doesn't say anything about it. Even more confusing is the fact that if you specify a path to a file that does not have the .json extension, but is still a valid key, you get cryptic errors such as Error: Getting metadata from plugin failed with error: email is required., which wasn't really pointing me in the right direction to figure this one out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants