GoogleAPIsAuthJWT.authorize()

Get authorization tokens

Usage

Hover over inputs/exits for more info.

var GoogleAPIsAuthJWT = require('machinepack-googleapisauthjwt');


// Get authorization tokens

GoogleAPIsAuthJWT.authorize({

email: 'service-account-email@developer.gserviceaccount.com',

keyFile: 'path/to/key.pem',

key: 'keyContent',

scopes: [ 'https://www.googleapis.com/auth/drive.readonly' ],

impersonateEmail: 'subject-account-email@example.com',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function () {

 

},

});

Inputs

email required

Service account email

'service-account-email@developer.gserviceaccount.com'
keyFile

Path to your generated key.pem

'path/to/key.pem'
key

Contents of private_key.pem if you want to load the pem file yourself. (do not use the path parameter above if using this param)

'keyContent'
scopes

Scopes can be specified either as an array or as a single, space-delimited string

[ 'https://www.googleapis.com/auth/drive.readonly' ]
impersonateEmail

User to impersonate (leave empty if no impersonation needed)

'subject-account-email@example.com'

Exits

error

An unexpected error occurred.

success

OK.