// [START get_service_account_tokens]
var admin = require("firebase-admin");

var serviceAccount = require("path/to/serviceAccountKey.json");
var credential = admin.credential.cert(serviceAccount);

var accessTokenInfo = credential.getAccessToken();
var accessToken = accessTokenInfo.access_token;
var expirationTime = accessTokenInfo.expires_in;
// Attach accessToken to HTTPS request in the "Authorization: Bearer" header
// After expirationTime, you must generate a new access token
// [END get_service_account_tokens]

console.log("The token " + accessToken + " expires in " + expirationTime);

// [START get_service_account_tokens]
var admin = require("firebase-admin");

var serviceAccount = require("path/to/serviceAccountKey.json");
var credential = admin.credential.cert(serviceAccount);

var accessTokenInfo = credential.getAccessToken().then(function(accessTokenInfo) {
  var accessToken = accessTokenInfo.access_token;
  var expirationTime = accessTokenInfo.expires_in;

  // Attach accessToken to HTTPS request in the "Authorization: Bearer" header
  // After expirationTime, you must generate a new access token
  // [START_EXCLUDE]
  console.log("The token " + accessToken + " expires in " + expirationTime);
  // [END_EXCLUDE]
});
// [END get_service_account_tokens]


Fix Node.js Admin SDK snippet
Fix Node.js Admin SDK snippet

Change-Id: Ib79a490e48e418c08ff70d3b2a31b32ec9c3b654
