Medium/google-auth-library-nodejs

Name: google-auth-library-nodejs

Owner: Medium

Description: Google Auth Library for Node.js

Created: 2015-10-01 19:03:21.0

Updated: 2015-10-01 19:03:22.0

Pushed: 2015-10-01 20:32:02.0

Homepage:

Size: 242

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Google APIs Node.js Client

Build Status Code Coverage

This is Google's officially supported node.js client library for using OAuth 2.0 authorization and authentication with Google APIs.

Alpha

This library is in Alpha. We will make an effort to support the library, but we reserve the right to make incompatible changes when necessary.

Questions/problems?
Installation

This library is distributed on npm. To add it as a dependency, run the following command:

m install google-auth-library --save
License

This library is licensed under Apache 2.0. Full license text is available in COPYING.

Example Usage
google = require('googleapis');

et the environment configured authorization
le.auth.getApplicationDefault(function(err, authClient) {
 (err === null) {
// Inject scopes if they have not been injected by the environment
if (authClient.createScopedRequired && authClient.createScopedRequired()) {
  var scopes = [
    'https://www.googleapis.com/auth/cloud-platform',
    'https://www.googleapis.com/auth/compute'
  ];
  authClient = authClient.createScoped(scopes)
}

// Fetch the access token
var _ = require(lodash);
var optionalUri = null;  // optionally specify the URI being authorized
var reqHeaders = {};
authClient.getRequestMetadata(optionalUri, function(err, headers)) {
  if (err === null) {
    // Use authorization headers
    reqHeaders = _.merge(allHeaders, headers);
  }
});


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.

Contributing

See CONTRIBUTING.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.