Skip to content

Error: Missing key, key or keyFile option must be provided! #261

Closed

Description

@Lordink

While using gcloud on my own local server, I write:

var gcloud = require('gcloud');
var bucket;

bucket = gcloud.storage.bucket({
    projectId: 'myProjectName',
    keyFilename: 'resources/key.json',
    bucketName: 'testnameorwhatever'
});

bucket.write('demo.txt', 'Hello World', function(err) {
        var stuff = err || 'Created demo.txt'
        console.log(stuff);
});

if I do specify the right path to the key, it gives this output (not thrown error, just console log):
[Error: Missing key, key or keyFile option must be provided!]
I do not understand this message. There is a key specified, and the path to it is right. I know that, as if I write the wrong keyFilename path, it throws ENOENT error 34. So, is it about the key description or something?

Activity

  1. stephenplusplus commented on Oct 17, 2014

    @stephenplusplus
    Contributor

    Which version of gcloud-node are you using?

  2. Lordink commented on Oct 17, 2014

    @Lordink
    Author

    the latest one, I guess. 0.8.1

  3. stephenplusplus commented on Oct 17, 2014

    @stephenplusplus
    Contributor

    Can you verify that in yourproject/node_modules/gcloud-node/package.json? :)

  4. Lordink commented on Oct 17, 2014

    @Lordink
    Author

    Yeah, here is a fraction of it:

    {
      "name": "gcloud",
      "version": "0.8.1",
      "author": {
        "name": "Google Inc."
      },
      "description": "Google Cloud APIs Client Library for Node.js",
    ...
  5. stephenplusplus commented on Oct 17, 2014

    @stephenplusplus
    Contributor

    Thanks, I'll play around and try to find the 🐛

  6. Lordink commented on Oct 17, 2014

    @Lordink
    Author

    Just in case I am dumb and use the wrong key, my key json has these fields in it:

    {"web":{"auth_uri":"https://accounts.google.com/o/oauth2/auth", "client_secret": ..., "token_uri":...

    and so on. Is that the right key? :)

  7. stephenplusplus commented on Oct 17, 2014

    @stephenplusplus
    Contributor

    Not dumb at all! There are a million things you can do in the Developers Console, it's very easy to get lost.

    I believe you are using a client ID for a webapp, where what we want is a service account. https://github.com/GoogleCloudPlatform/gcloud-node/#elsewhere step 4 should show how to do that.

    I'm going to close as I was able to reproduce the same error with a webapp key, and remedy it with a service key. If you run into anything else, ask away!

  8. ryanseys commented on Oct 17, 2014

    @ryanseys
    Contributor

    I'd say this issue comes down to a misunderstanding of the error message. The error itself is suggesting that a keyFile or key parameter should be specified, when really the error should suggest that they are likely using an invalid key file. Should we improve this err message?

  9. ryanseys commented on Oct 17, 2014

    @ryanseys
    Contributor

    Seems the error is created in gapitoken so we have no control over the error message, unless we do some of our own sanity checking when passing in the key / key file.

  10. thebergamo commented on Nov 5, 2014

    @thebergamo

    I'm try to use the same feature and I've the same error.

    Have a fix to this problem?

  11. stephenplusplus commented on Nov 5, 2014

    @stephenplusplus
    Contributor
  12. thebergamo commented on Nov 5, 2014

    @thebergamo

    Nothing... I try to pass the client_email and the private_key manual, but I recive this error:

    12176:error:0906D06C:PEM routines:PEM_read_bio:no start line:openssl\crypto\pem\pem_lib.c:703:Expecting: ANY PRIVATE KEY

  13. stephenplusplus commented on Nov 5, 2014

    @stephenplusplus
    Contributor

    You generated a service account JSON key from the developer's console, and it looked like:

    {
      "private_key_id": "...",
      "private_key": "...",
      "client_email": "...@developer.gserviceaccount.com",
      "client_id": "....apps.googleusercontent.com",
      "type": "service_account"
    }

    You instantiated gcloud like:

    require('gcloud')({
      credentials: {
        private_key: '...',
        client_email: '...@developer.gserviceaccount.com'
      }
    });

    and got that error?

    More code that shows what you're doing and full stack traces would help me debug.

  14. thebergamo commented on Nov 5, 2014

    @thebergamo

    My JSON not is in this format.

    The private_key have only ~16 chars. I'm almost on madness to solve this problem. :(

  15. 57 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions