lib/functions/authenticate.js
function getTokenCustom(code, oauth2Client) {
    return new Promise((resolve, reject) => {
        if (code) {
            oauth2Client.getToken(code, (err, newToken) => {
                if (err) {
                    reject(err);
                    return;
                }
                resolve(newToken);
                return;
            });
        } else {
            oauth2Client.refreshAccessToken((err, newToken) => {
                if (err) {
                    reject(err);
                }
                resolve(newToken);
                return;
            });
        }
    });
}
function getTokenCustom(code, oauth2Client) {
    return new Promise((resolve, reject) => {
        if (code) {
            oauth2Client.getToken(code, (err, newToken) => {
                if (err) {
                    reject(err);
                    return;
                }
                resolve(newToken);
                return;
            });
        } else {
            oauth2Client.refreshAccessToken((err, newToken) => {
                if (err) {
                    reject(err);
                }
                resolve(newToken);
                return;
            });
        }
    });
}
function getTokenCustom ( code , oauth2Client ) { return new Promise ( ( resolve , reject ) => { if ( code ) { oauth2Client . getToken ( code , ( err , newToken ) => { if ( err ) { reject ( err ) ; return ; } resolve ( newToken ) ; return ; } ) ; } else { oauth2Client . refreshAccessToken ( ( err , newToken ) => { if ( err ) { reject ( err ) ; } resolve ( newToken ) ; return ; } ) ; } } ) ; }
Get a token for a custom Oauth client.

@param {google.auth.OAuth2} code - Optional code to get token for.
@param {google.auth.OAuth2} oauth2Client - The OAuth2 client to get token for.
@returns {Promise} - A promise resolving a token
Get a token for a custom Oauth client .