UNPKG

@constructor-io/constructorio-connect-cli

Version:

CLI tool to enable users to interface with the Constructor Connect Ecosystem

26 lines (25 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.obtainToken = obtainToken; const axios_1 = require("axios"); const errors_1 = require("@oclif/core/errors"); const ux_action_1 = require("../helpers/ux-action"); const http_client_1 = require("./http-client"); async function obtainToken(args) { const client = await (0, http_client_1.getHttpClient)({ requiresAuth: false }); try { const response = await (0, ux_action_1.uxAction)("📡 Obtaining connect auth token", async () => { return await client.post(`/auth/obtain-token`, args); })(); return response.data.connect_auth_token; } catch (error) { if ((0, axios_1.isAxiosError)(error) && error.response) { throw new errors_1.CLIError("Something went wrong while obtaining connect auth token: \n" + error.response.data.message + "\n" + "Please reach out over at partners@constructor.io."); } throw error; } }