UNPKG

dfp-lib

Version:

This project hosts the Node.JS client library for the SOAP-based DFP API at Google.

26 lines (25 loc) 1.32 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const src_1 = require("../../../src"); const config_1 = require("./config"); (function () { return __awaiter(this, void 0, void 0, function* () { const user = new src_1.dfp.DfpUser(config_1.default); let oauth2Info = user.getOAuth2Info(); if (oauth2Info) { const oauth2Handler = user.getOAuth2Handler(); oauth2Info = yield oauth2Handler.getOrRefreshAccessToken(oauth2Info); user.setOAuth2Info(oauth2Info); if (oauth2Handler.isAccessTokenValid(oauth2Info)) { console.log('Access Token:', oauth2Handler.formatCredentialsForHeader(oauth2Info)); } } }); })().catch((err) => console.error(err));