UNPKG

@neurosity/sdk

Version:
12 lines (11 loc) 644 B
import axios from "axios"; import { getFunctionsBaseURL } from "./utils"; export function createOAuthURL(config, sdkOptions) { const { clientId, clientSecret, responseType, redirectUri, scope, state } = config; const baseUrl = getFunctionsBaseURL(sdkOptions); return axios .get(`${baseUrl}/authorize/entry`, { params: Object.assign(Object.assign({ client_id: clientId }, (clientSecret ? { client_secret: clientSecret } : {})), { response_type: responseType, redirect_uri: redirectUri, scope: scope.join(","), state: state, redirect: "false" }) }) .then((response) => `${baseUrl}${response.data.url}`); }