@guardian/google-admanager-api
Version:
Google Ad Manager API Client Library for NodeJs
30 lines • 981 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GoogleSAFileCredential = void 0;
const google_auth_library_1 = require("google-auth-library");
const constants_1 = require("../common/constants");
class GoogleSAFileCredential {
/**
*
* @param keyFile Path to a .json, .pem, or .p12 key file
*/
constructor(keyFile) {
if (!keyFile) {
throw new Error("'keyFile' must be set when using service account flow.");
}
this._keyFile = keyFile;
this.build();
}
async build() {
this.auth = new google_auth_library_1.GoogleAuth({
keyFile: this._keyFile,
scopes: constants_1.SCOPE,
});
}
async getToken() {
var _a;
return await ((_a = this.auth) === null || _a === void 0 ? void 0 : _a.getAccessToken());
}
}
exports.GoogleSAFileCredential = GoogleSAFileCredential;
//# sourceMappingURL=googleSAFileCredential.js.map