Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 1.8 KB

File metadata and controls

31 lines (20 loc) · 1.8 KB

Authenticating with this module

It's incredibly easy to get authenticated and start using Google's APIs. You can set your credentials on a global basis as well as on a per-API basis. See each individual API section below to see how you can auth on a per-API-basis. This is useful if you want to use different accounts for different Cloud services.

var config = {
  projectId: 'grape-spaceship-123',
  keyFilename: '/path/to/keyfile.json'
};

The config object

A config object is not required if you are in an environment which supports Application Default Credentials. This could be your own development machine when using the gcloud SDK or within Google App Engine and Compute Engine. How you set up Application Default Credentials depends on where your code is running.

If this doesn't describe your environment, the config object expects the following properties:

  1. One of the following:

  2. credentials object containing client_email and private_key properties.

  3. keyFilename path to a .json, .pem, or .p12 key file.

  4. GOOGLE_APPLICATION_CREDENTIALS environment variable with a full path to your key file.

  5. projectId

If you wish, you can set an environment variable (GOOGLE_CLOUD_PROJECT) in place of specifying this inline. Or, if you have provided a service account JSON key file as the config.keyFilename property explained above, your project ID will be detected automatically.

Note: When using a .pem or .p12 key file, config.email is also required.