Google APIs Node.js Client
This is Google's officially supported node.js client library for using OAuth 2.0 authorization and authentication with Google APIs.
- Ask your development related questions on
- If you've found an bug/issue, please file it on GitHub.
This library is distributed on
npm. To add it as a dependency,
run the following command:
$ npm install google-auth-library --save
Application Default Credentials
This library provides an implementation of Application Default Credentials for Node.js.
The Application Default Credentials provide a simple way to get authorization credentials for use in calling Google APIs.
They are best suited for cases when the call needs to have the same identity and authorization level for the application independent of the user. This is the recommended approach to authorize calls to Cloud APIs, particularly when you're building an application that uses Google Compute Engine.
Download your Service Account Credentials JSON file
Application Default Credentials, You first need to download a set of
JSON credentials for your project. Go to APIs & Auth > Credentials in
the Google Developers Console and select
Service account from the Add credentials dropdown.
This file is your only copy of these credentials. It should never be committed with your source code, and should be stored securely.
Once downloaded, store the path to this file in the
GOOGLE_APPLICATION_CREDENTIALS environment variable.
Enable the API you want to use
Before making your API call, you must be sure the API you're calling has been
enabled. Go to APIs & Auth > APIs in the
Google Developers Console and enable the APIs you'd like to
call. For the example below, you must enable the
Call an API
As long as you update the environment variable below to point to your JSON credentials file, and the fill in the placeholder variables from your project, the following snippet should work.
var google = ;var GoogleAuth = ;var authFactory = ;var dns = google;authFactory;
This library is licensed under Apache 2.0. Full license text is available in LICENSE.