Packages

google-auth-library

11.3.4 · 9 Nov 2026Apache-2.0145.3M / weekRepositoryHomepagenpmAtom feed

Your version

2.0.0

major30 Aug 2018Where it was published

2.0.2 is the newest release of 2.x.

In short

4 breaking4 deprecated3 new9 fixed2 changed22 internal

  • Breaking

    Well hello 2.0 🎉 This release has multiple breaking changes.

  • Breaking

    These versions of node.js are no longer supported.

  • Breaking

    Drop support for node.js 4.x and 9.x

  • Breaking

    Drop support for node.js 4

  • Deprecated

    Deprecate getRequestMetadata

  • Deprecated

    Deprecate the createScopedRequired methods

  • Deprecated

    Deprecate the refreshAccessToken methods

  • Deprecated

    Deprecate the getDefaultProjectId method

Release note

The section about google-auth-library of a note shared by several packages.

Well hello 2.0 🎉 This release has multiple breaking changes. It also has a lot of bug fixes.

Breaking Changes

Support for node.js 4.x and 9.x has been dropped

These versions of node.js are no longer supported.

The getRequestMetadata method has been deprecated

The getRequestMetadata method has been deprecated on the IAM, OAuth2, JWT, and JWTAccess classes. The getRequestHeaders method should be used instead. The methods have a subtle difference: the getRequestMetadata method returns an object with a headers property, which contains the authorization header. The getRequestHeaders method simply returns the headers.

Old code

const client = await auth.getClient();
const res = await client.getRequestMetadata();
const headers = res.headers;

New code

const client = await auth.getClient();
const headers = await client.getRequestHeaders();

The createScopedRequired method has been deprecated

The createScopedRequired method has been deprecated on multiple classes. The createScopedRequired and createScoped methods on the JWT class were largely in place to help inform clients when scopes were required in an application default credential scenario. Instead of checking if scopes are required after creating the client, instead scopes should just be passed either into the GoogleAuth.getClient method, or directly into the JWT constructor.

Old code

auth.getApplicationDefault(function(err, authClient) {
   if (err) {
     return callback(err);
   }
  if (authClient.createScopedRequired && authClient.createScopedRequired()) {
    authClient = authClient.createScoped([
      'https://www.googleapis.com/auth/cloud-platform'
    ]);
  }
  callback(null, authClient);
});

New code

const client = await auth.getClient({
  scopes: ['https://www.googleapis.com/auth/cloud-platform']
});

Deprecate refreshAccessToken

Note: refreshAccessToken is no longer deprecated.

getAccessToken, getRequestMetadata, and request methods will all refresh the token if needed automatically.

You should not need to invoke refreshAccessToken directly except in certain edge-cases.

Features

  • Set private_key_id in JWT access token header like other google auth libraries.

Bug Fixes

  • Support HTTPS proxies

  • Export missing interfaces

  • Use new auth URIs

  • Surface file read streams

  • Prevent unhandled rejections by avoid .catch

  • Use gcp-metadata for compute credentials

  • Add Code of Conduct

  • Warn when using user credentials from the Cloud SDK

  • Use Buffer.from instead of new Buffer

  • Fix link format in README.md

Breaking changes

  • Deprecated

    Deprecate getRequestMetadata

  • Deprecated

    Deprecate the createScopedRequired methods

  • Breaking

    Drop support for node.js 4.x and 9.x

  • Deprecated

    Deprecate the refreshAccessToken methods

  • Deprecated

    Deprecate the getDefaultProjectId method

  • Breaking

    Drop support for node.js 4

Build / Test changes

  • Run synth to make build tools consistent

  • Add a package.json for samples and cleanup README

  • cleanup: Straighten nested try-catch

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.