UNPKG

@niur/google-admanager-api

Version:
31 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GoogleSACredential = void 0; const google_auth_library_1 = require("google-auth-library"); const constants_1 = require("../common/constants"); class GoogleSACredential { /** * * @param json The input object. * @param options The JWT or UserRefresh options for the client */ constructor(json, options) { if (!json) { throw new Error("'json' must be set when using service account flow."); } this.json = json; this.options = options; this.build(); } async build() { const json = typeof this.json === 'string' ? JSON.parse(this.json) : this.json; this.auth = new google_auth_library_1.GoogleAuth({ scopes: constants_1.SCOPE, }).fromJSON(json, this.options); } async getToken() { return await (await this.auth.getAccessToken()).token; } } exports.GoogleSACredential = GoogleSACredential; //# sourceMappingURL=googleSACredential.js.map