function authorize(credentials) {
    const { client_secret, client_id, redirect_uris } = credentials.installed;
    const oAuth2Client = new googleapis_1.google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
    try {
        const token = fs_1.default.readFileSync(TOKEN_PATH);
        oAuth2Client.setCredentials(JSON.parse(token.toString()));
        console.log('Token parsed');
        return Promise.resolve(oAuth2Client);
    }
    catch (_a) {
        return getAccessToken(oAuth2Client);
    }
}
/**
 * Create an OAuth2 client with the given credentials, and then execute the
 * given callback function.
 * @param {Object} credentials The authorization client credentials.
 * @param {function} callback The callback to call with the authorized client.
 */
Create an OAuth2 client with the given credentials, and then execute the
given callback function.
@param {Object} credentials The authorization client credentials.
@param {function} callback The callback to call with the authorized client.
Create an OAuth2 client with the given credentials and then execute the given callback function . @param { Object } credentials The authorization client credentials . @param { function } callback The callback to call with the authorized client .
function authorize(credentials) {
    const { client_secret, client_id, redirect_uris } = credentials.installed;
    const oAuth2Client = new googleapis_1.google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
    try {
        const token = fs_1.default.readFileSync(TOKEN_PATH);
        oAuth2Client.setCredentials(JSON.parse(token.toString()));
        console.log('Token parsed');
        return Promise.resolve(oAuth2Client);
    }
    catch (_a) {
        return getAccessToken(oAuth2Client);
    }
}
function authorize ( credentials ) { const { client_secret , client_id , redirect_uris } = credentials . installed ; const oAuth2Client = new googleapis_1 . google . auth . OAuth2 ( client_id , client_secret , redirect_uris [ 0 ] ) ; try { const token = fs_1 . default . readFileSync ( TOKEN_PATH ) ; oAuth2Client . setCredentials ( JSON . parse ( token . toString ( ) ) ) ; console . log ( 'Token parsed' ) ; return Promise . resolve ( oAuth2Client ) ; } catch ( _a ) { return getAccessToken ( oAuth2Client ) ; } }
Create an OAuth2 client with the given credentials, and then execute the
 given callback function.
Create an OAuth2 client with the given credentials and then execute the given callback function .