From 2e78919242f208f121d311b1cab7853a619f5a67 Mon Sep 17 00:00:00 2001 From: Vinay Devalla <> Date: Thu, 25 Feb 2021 09:18:03 -0500 Subject: [PATCH] Added code for getConfigForTokenFetch --- src/destination.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/destination.js b/src/destination.js index 71e242a..7b07327 100644 --- a/src/destination.js +++ b/src/destination.js @@ -194,6 +194,28 @@ function createJwtTokenForGCPServiceAccount(cfDestinationInfo) { }); } +function getConfigForTokenFetch(config) { + let tokenConfig = { + baseURL: config.baseURL, + url: "/$metadata", + method: "GET", + headers: Object.assign(config.headers || {}, { + "X-CSRF-Token": "Fetch", + "Connection": "keep-alive" + }) + }; + if (config.proxy) { + tokenConfig.proxy = Object.assign({}, config.proxy); + } + + if (process.env.DEBUG === "true") { + console.log(tokenConfig); + } + + return tokenConfig; +} + + function getAxiosConfig(options, cfDestinationInfo, connectivity) { return new Promise((resolve, reject) => { var config = Object.assign({}, options);