UNPKG

citi-hub-session-engine

Version:

Module for authentication methods for CITI hub

33 lines (26 loc) 943 B
const { logger } = require("../utils/Logger"); const { configurations_key } = require("../utils/Constants"); const addUserScopes = async (token, body) => { try { logger.info(`Initiating addUserScopes`); const config = global[configurations_key]; let endpoint = config?.addUsersScopes?.endpoint || ""; logger.info(`endpoint: ${endpoint}`); //INVOKE ENDPOINT, GET, headers: authorization, body: params const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, }, body: JSON.stringify(body), }); const data = await response.json(); logger.info(`Response from addUserScopes: ${data.code}`); return data; } catch (e) { logger.error(`An error occurred while addUserScopes :: ${e}`); return null; } }; module.exports = addUserScopes;