Getting a token with google service account (jwt)


I try to connect to the firebase REST API :

so I need a google oauth2 access tokens. Google provide 3 sets of client library, JAVA, NODE.JS and PYTHON
of course no coldfusion.
I found this project :
but it stand : “The token can be your secret, but is less secure than generating a JWT that expires or based on a $uid with a library like the awesome cf-simple-jwt”
of course the awesome library cf-jwt-simple is far to be as simple as the NODE.JS version of the library …:

Anyone managed to get an access token from a google service account with a json file ? a really need an example …

Thanks for your help

PS : the solution with the node.js lib is straightforward :

var google = require("googleapis");

// Load the service account key JSON file.
var serviceAccount = require("./myjsonfile.json");

// Define the required scopes.
var scopes = [

// Authenticate a JWT client with the service account.
var jwtClient = new google.auth.JWT(

// Use the JWT client to generate an access token.
jwtClient.authorize(function(error, tokens) {
  if (error) {
    console.log("Error making request to generate access token:", error);
  } else if (tokens.access_token === null) {
    console.log("Provided service account does not have permission to generate access tokens");
  } else {
    var accessToken = tokens.access_token;
    console.log("Access tokens "+ accessToken);
    // See the "Using the access token" section below for information
    // on how to use the access token to send authenticated requests to
    // the Realtime Database REST API.


@Stephane_MERLE, did you have any luck with this? I’m trying to do the same as what you are trying to do, with google cloud printing services.