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'
};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:
-
One of the following:
-
credentialsobject containingclient_emailandprivate_keyproperties. -
keyFilenamepath to a .json, .pem, or .p12 key file. -
GOOGLE_APPLICATION_CREDENTIALSenvironment variable with a full path to your key file. -
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.