UNPKG

@guardian/google-admanager-api

Version:

Google Ad Manager API Client Library for NodeJs

32 lines 1.17 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() { var _a, _b; return (_b = (await ((_a = this.auth) === null || _a === void 0 ? void 0 : _a.getAccessToken()))) === null || _b === void 0 ? void 0 : _b.token; } } exports.GoogleSACredential = GoogleSACredential; //# sourceMappingURL=googleSACredential.js.map