ToolJet/plugins/packages/restapi/lib/index.ts

351 lines
12 KiB
TypeScript
Raw Normal View History

Move plugins to root (#1728) * feat: move plugins to root * modify tsconfig * add .gitignore * delete old plugins file * add parcel * docker compose volume mount * add gcs * add typescript to plugins folder * gcs to ts * add dynamodb * add elastic search * add firestore * add gsheets * add graphql * add mongodb * mssql * add mysql * add postgresql * add redis * add s3 * add slack * add stripe * remove plugin related packages from pkgjson * add lib folder * add gitignore * remove typescript generated files * remove generated file * remove generated files * add twilio * add dist to docker compose cache binding * add dist prefix * cleanup - 1 * delete dist * rename to index.ts + add jest config * add it.todo in tests * test fixes * test file changes * fix type checks * add @tooljet/plugins to server package json * esm vs commonjs bug, reduce got to 11.8.2 from 12.0.0 * docker file npm package version fix * add typesense * cleaup - 2 * add sendgrid * add lerna build and clean script for all packages + tsconfig * cleanup -3 * add plugins build step * add missing plugins build step in npm run build * add mssql, mysql & postgres as singleton classes * add db connection to cache only if datasourceId is available * client: add data source schema/manifest files * add query operations files * logic for wrapping form with schema * add script to create index file * add @tooljet/plugins to frontend folder * cleanup 1 -frontend * cleanup - 2 // frontend // data queries * add client and index to gitignore * update gitignore * fix lint & test * update ci * fix unit, e2e * cleanup -3 * fix test * fix tests * fix indent * try npm ci * fix tests * fix typo * fix * rename file for server entry * heroku fix * add main and types entry points in pkg json * move common to root * cleanup - 4: remove redundant $ sign prefix * cleanup - 4: remove redundant $ sign prefix * update options in-sync before DOM is painted * change type cloud to cloud storage * update readme * update ci.yml * update ci yml * add pkg-lock.json * rename index.ts to server.ts * update lock files * add server package.lock * remove unused import * revert commit: add minio * add root dep * import server.ts * remove plugins build step * add npm shrinkwrap * update version - plugins * add new version - 0.0.8 * upgrade version * move to symlinked package * add lock file * feat: add icon inside package * add plugin creation docs * Remove seed * move icons to plugins folder * install pg dep * add react to packages * add seed cmd * revert change * add plugins build in lint, e2e, unit * e2e, lint use npm ci * update dockerfile for plugins * try combining release with web * limit memory on release * try executing seed script post transpile * try executing seed from server directory * update seed execution * add minio * add correct type * add minio to pkg json * remove old file * fix provider key * add python installable + npm ^7.2.0 (#1752) * add python installable + npm ^7.2.0 * add py to prod file * pin npm version to 7.20.0 * pin npm version to 7.20.0 * split into multi stage build and remove python for buildx * copy plugins from buider stage * update dependencies * add freetds dependency * update server dockerfile * update client dockerfile * update dev dockerfile and compose file * fix entrypoint * fix server dev dockerfile * update docker-compose * remove npm install on root dir on docker build * fix heroku script * make lerna prod dependency to enable prod builds * remove redundant env setup Co-authored-by: Akshay Sasidharan <akshaysasidharan93@gmail.com> Co-authored-by: navaneeth <navaneethpk@outlook.com>
2022-01-17 07:08:17 +00:00
const urrl = require('url');
import { readFileSync } from 'fs';
import * as tls from 'tls';
import {
QueryError,
QueryResult,
QueryService,
cleanSensitiveData,
User,
App,
getCurrentToken,
OAuthUnauthorizedClientError,
} from '@tooljet-plugins/common';
const JSON5 = require('json5');
import got, { Headers, HTTPError, OptionsOfTextResponseBody } from 'got';
import { SourceOptions } from './types';
Move plugins to root (#1728) * feat: move plugins to root * modify tsconfig * add .gitignore * delete old plugins file * add parcel * docker compose volume mount * add gcs * add typescript to plugins folder * gcs to ts * add dynamodb * add elastic search * add firestore * add gsheets * add graphql * add mongodb * mssql * add mysql * add postgresql * add redis * add s3 * add slack * add stripe * remove plugin related packages from pkgjson * add lib folder * add gitignore * remove typescript generated files * remove generated file * remove generated files * add twilio * add dist to docker compose cache binding * add dist prefix * cleanup - 1 * delete dist * rename to index.ts + add jest config * add it.todo in tests * test fixes * test file changes * fix type checks * add @tooljet/plugins to server package json * esm vs commonjs bug, reduce got to 11.8.2 from 12.0.0 * docker file npm package version fix * add typesense * cleaup - 2 * add sendgrid * add lerna build and clean script for all packages + tsconfig * cleanup -3 * add plugins build step * add missing plugins build step in npm run build * add mssql, mysql & postgres as singleton classes * add db connection to cache only if datasourceId is available * client: add data source schema/manifest files * add query operations files * logic for wrapping form with schema * add script to create index file * add @tooljet/plugins to frontend folder * cleanup 1 -frontend * cleanup - 2 // frontend // data queries * add client and index to gitignore * update gitignore * fix lint & test * update ci * fix unit, e2e * cleanup -3 * fix test * fix tests * fix indent * try npm ci * fix tests * fix typo * fix * rename file for server entry * heroku fix * add main and types entry points in pkg json * move common to root * cleanup - 4: remove redundant $ sign prefix * cleanup - 4: remove redundant $ sign prefix * update options in-sync before DOM is painted * change type cloud to cloud storage * update readme * update ci.yml * update ci yml * add pkg-lock.json * rename index.ts to server.ts * update lock files * add server package.lock * remove unused import * revert commit: add minio * add root dep * import server.ts * remove plugins build step * add npm shrinkwrap * update version - plugins * add new version - 0.0.8 * upgrade version * move to symlinked package * add lock file * feat: add icon inside package * add plugin creation docs * Remove seed * move icons to plugins folder * install pg dep * add react to packages * add seed cmd * revert change * add plugins build in lint, e2e, unit * e2e, lint use npm ci * update dockerfile for plugins * try combining release with web * limit memory on release * try executing seed script post transpile * try executing seed from server directory * update seed execution * add minio * add correct type * add minio to pkg json * remove old file * fix provider key * add python installable + npm ^7.2.0 (#1752) * add python installable + npm ^7.2.0 * add py to prod file * pin npm version to 7.20.0 * pin npm version to 7.20.0 * split into multi stage build and remove python for buildx * copy plugins from buider stage * update dependencies * add freetds dependency * update server dockerfile * update client dockerfile * update dev dockerfile and compose file * fix entrypoint * fix server dev dockerfile * update docker-compose * remove npm install on root dir on docker build * fix heroku script * make lerna prod dependency to enable prod builds * remove redundant env setup Co-authored-by: Akshay Sasidharan <akshaysasidharan93@gmail.com> Co-authored-by: navaneeth <navaneethpk@outlook.com>
2022-01-17 07:08:17 +00:00
function isEmpty(value: number | null | undefined | string) {
return (
value === undefined ||
value === null ||
!isNaN(value as number) ||
(typeof value === 'object' && Object.keys(value).length === 0) ||
(typeof value === 'string' && value.trim().length === 0)
);
Move plugins to root (#1728) * feat: move plugins to root * modify tsconfig * add .gitignore * delete old plugins file * add parcel * docker compose volume mount * add gcs * add typescript to plugins folder * gcs to ts * add dynamodb * add elastic search * add firestore * add gsheets * add graphql * add mongodb * mssql * add mysql * add postgresql * add redis * add s3 * add slack * add stripe * remove plugin related packages from pkgjson * add lib folder * add gitignore * remove typescript generated files * remove generated file * remove generated files * add twilio * add dist to docker compose cache binding * add dist prefix * cleanup - 1 * delete dist * rename to index.ts + add jest config * add it.todo in tests * test fixes * test file changes * fix type checks * add @tooljet/plugins to server package json * esm vs commonjs bug, reduce got to 11.8.2 from 12.0.0 * docker file npm package version fix * add typesense * cleaup - 2 * add sendgrid * add lerna build and clean script for all packages + tsconfig * cleanup -3 * add plugins build step * add missing plugins build step in npm run build * add mssql, mysql & postgres as singleton classes * add db connection to cache only if datasourceId is available * client: add data source schema/manifest files * add query operations files * logic for wrapping form with schema * add script to create index file * add @tooljet/plugins to frontend folder * cleanup 1 -frontend * cleanup - 2 // frontend // data queries * add client and index to gitignore * update gitignore * fix lint & test * update ci * fix unit, e2e * cleanup -3 * fix test * fix tests * fix indent * try npm ci * fix tests * fix typo * fix * rename file for server entry * heroku fix * add main and types entry points in pkg json * move common to root * cleanup - 4: remove redundant $ sign prefix * cleanup - 4: remove redundant $ sign prefix * update options in-sync before DOM is painted * change type cloud to cloud storage * update readme * update ci.yml * update ci yml * add pkg-lock.json * rename index.ts to server.ts * update lock files * add server package.lock * remove unused import * revert commit: add minio * add root dep * import server.ts * remove plugins build step * add npm shrinkwrap * update version - plugins * add new version - 0.0.8 * upgrade version * move to symlinked package * add lock file * feat: add icon inside package * add plugin creation docs * Remove seed * move icons to plugins folder * install pg dep * add react to packages * add seed cmd * revert change * add plugins build in lint, e2e, unit * e2e, lint use npm ci * update dockerfile for plugins * try combining release with web * limit memory on release * try executing seed script post transpile * try executing seed from server directory * update seed execution * add minio * add correct type * add minio to pkg json * remove old file * fix provider key * add python installable + npm ^7.2.0 (#1752) * add python installable + npm ^7.2.0 * add py to prod file * pin npm version to 7.20.0 * pin npm version to 7.20.0 * split into multi stage build and remove python for buildx * copy plugins from buider stage * update dependencies * add freetds dependency * update server dockerfile * update client dockerfile * update dev dockerfile and compose file * fix entrypoint * fix server dev dockerfile * update docker-compose * remove npm install on root dir on docker build * fix heroku script * make lerna prod dependency to enable prod builds * remove redundant env setup Co-authored-by: Akshay Sasidharan <akshaysasidharan93@gmail.com> Co-authored-by: navaneeth <navaneethpk@outlook.com>
2022-01-17 07:08:17 +00:00
}
2021-07-17 14:22:37 +00:00
function sanitizeCustomParams(customArray: any) {
const params = Object.fromEntries(customArray ?? []);
Object.keys(params).forEach((key) => (params[key] === '' ? delete params[key] : {}));
return params;
}
interface RestAPIResult extends QueryResult {
request?: Array<object> | object;
response?: Array<object> | object;
responseHeaders?: Array<object> | object;
}
2021-07-17 14:22:37 +00:00
export default class RestapiQueryService implements QueryService {
authUrl(sourceOptions: SourceOptions): string {
const customQueryParams = sanitizeCustomParams(sourceOptions['custom_query_params']);
const tooljetHost = process.env.TOOLJET_HOST;
const authUrl = new URL(
`${sourceOptions['auth_url']}?response_type=code&client_id=${sourceOptions['client_id']}&redirect_uri=${tooljetHost}/oauth2/authorize&scope=${sourceOptions['scopes']}`
);
Object.entries(customQueryParams).map(([key, value]) => authUrl.searchParams.append(key, value));
return authUrl.toString();
}
/* Headers of the source will be overridden by headers of the query */
Move plugins to root (#1728) * feat: move plugins to root * modify tsconfig * add .gitignore * delete old plugins file * add parcel * docker compose volume mount * add gcs * add typescript to plugins folder * gcs to ts * add dynamodb * add elastic search * add firestore * add gsheets * add graphql * add mongodb * mssql * add mysql * add postgresql * add redis * add s3 * add slack * add stripe * remove plugin related packages from pkgjson * add lib folder * add gitignore * remove typescript generated files * remove generated file * remove generated files * add twilio * add dist to docker compose cache binding * add dist prefix * cleanup - 1 * delete dist * rename to index.ts + add jest config * add it.todo in tests * test fixes * test file changes * fix type checks * add @tooljet/plugins to server package json * esm vs commonjs bug, reduce got to 11.8.2 from 12.0.0 * docker file npm package version fix * add typesense * cleaup - 2 * add sendgrid * add lerna build and clean script for all packages + tsconfig * cleanup -3 * add plugins build step * add missing plugins build step in npm run build * add mssql, mysql & postgres as singleton classes * add db connection to cache only if datasourceId is available * client: add data source schema/manifest files * add query operations files * logic for wrapping form with schema * add script to create index file * add @tooljet/plugins to frontend folder * cleanup 1 -frontend * cleanup - 2 // frontend // data queries * add client and index to gitignore * update gitignore * fix lint & test * update ci * fix unit, e2e * cleanup -3 * fix test * fix tests * fix indent * try npm ci * fix tests * fix typo * fix * rename file for server entry * heroku fix * add main and types entry points in pkg json * move common to root * cleanup - 4: remove redundant $ sign prefix * cleanup - 4: remove redundant $ sign prefix * update options in-sync before DOM is painted * change type cloud to cloud storage * update readme * update ci.yml * update ci yml * add pkg-lock.json * rename index.ts to server.ts * update lock files * add server package.lock * remove unused import * revert commit: add minio * add root dep * import server.ts * remove plugins build step * add npm shrinkwrap * update version - plugins * add new version - 0.0.8 * upgrade version * move to symlinked package * add lock file * feat: add icon inside package * add plugin creation docs * Remove seed * move icons to plugins folder * install pg dep * add react to packages * add seed cmd * revert change * add plugins build in lint, e2e, unit * e2e, lint use npm ci * update dockerfile for plugins * try combining release with web * limit memory on release * try executing seed script post transpile * try executing seed from server directory * update seed execution * add minio * add correct type * add minio to pkg json * remove old file * fix provider key * add python installable + npm ^7.2.0 (#1752) * add python installable + npm ^7.2.0 * add py to prod file * pin npm version to 7.20.0 * pin npm version to 7.20.0 * split into multi stage build and remove python for buildx * copy plugins from buider stage * update dependencies * add freetds dependency * update server dockerfile * update client dockerfile * update dev dockerfile and compose file * fix entrypoint * fix server dev dockerfile * update docker-compose * remove npm install on root dir on docker build * fix heroku script * make lerna prod dependency to enable prod builds * remove redundant env setup Co-authored-by: Akshay Sasidharan <akshaysasidharan93@gmail.com> Co-authored-by: navaneeth <navaneethpk@outlook.com>
2022-01-17 07:08:17 +00:00
headers(sourceOptions: any, queryOptions: any, hasDataSource: boolean): Headers {
const _headers = (queryOptions.headers || []).filter((o) => {
return o.some((e) => !isEmpty(e));
});
if (!hasDataSource) return Object.fromEntries(_headers);
const headerData = _headers.concat(sourceOptions.headers || []);
const headers = Object.fromEntries(headerData);
Object.keys(headers).forEach((key) => (headers[key] === '' ? delete headers[key] : {}));
return headers;
}
/* Body params of the source will be overridden by body params of the query */
body(sourceOptions: any, queryOptions: any, hasDataSource: boolean): object {
const bodyToggle = queryOptions['body_toggle'];
if (bodyToggle) {
const jsonBody = queryOptions['json_body'];
if (!jsonBody) return undefined;
if (typeof jsonBody === 'string') return JSON5.parse(jsonBody);
else return jsonBody;
} else {
const _body = (queryOptions.body || []).filter((o) => {
return o.some((e) => !isEmpty(e));
});
if (!hasDataSource) return Object.fromEntries(_body);
const bodyParams = _body.concat(sourceOptions.body || []);
return Object.fromEntries(bodyParams);
}
}
/* Search params of the source will be overridden by Search params of the query */
searchParams(sourceOptions: any, queryOptions: any, hasDataSource: boolean): object {
const _urlParams = (queryOptions.url_params || []).filter((o) => {
return o.some((e) => !isEmpty(e));
});
if (!hasDataSource) return Object.fromEntries(_urlParams);
const urlParams = _urlParams.concat(sourceOptions.url_params || []);
return Object.fromEntries(urlParams);
}
isJson(str: string) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
async run(
sourceOptions: any,
queryOptions: any,
dataSourceId: string,
dataSourceUpdatedAt: string,
context?: { user?: User; app?: App }
): Promise<RestAPIResult> {
/* REST API queries can be adhoc or associated with a REST API datasource */
const hasDataSource = dataSourceId !== undefined;
const authType = sourceOptions['auth_type'];
const requiresOauth = authType === 'oauth2';
const headers = this.headers(sourceOptions, queryOptions, hasDataSource);
const isUrlEncoded = this.checkIfContentTypeIsURLenc(queryOptions['headers']);
const isMultiAuthEnabled = sourceOptions['multiple_auth_enabled'];
/* Chceck if OAuth tokens exists for the source if query requires OAuth */
if (requiresOauth) {
const tokenData = sourceOptions['tokenData'];
const isAppPublic = context?.app.isPublic;
const userData = context?.user;
const currentToken = getCurrentToken(isMultiAuthEnabled, tokenData, userData?.id, isAppPublic);
if (!currentToken && !userData?.id && isAppPublic) {
throw new QueryError('Missing access token', {}, {});
}
if (!currentToken) {
return {
status: 'needs_oauth',
data: { auth_url: this.authUrl(sourceOptions) },
};
} else {
const accessToken = currentToken['access_token'];
if (sourceOptions['add_token_to'] === 'header') {
const headerPrefix = sourceOptions['header_prefix'];
headers['Authorization'] = `${headerPrefix}${accessToken}`;
}
}
}
let result = {};
let requestObject = {};
let responseObject = {};
let responseHeaders = {};
/* Prefixing the base url of datasource if datasource exists */
Feature - Multi Environment support (#4833) * initial commit * multi env changes * multi-env changes * entity fixes * data query changes * fix * trying to avoid conflict with EE * moved version creation to app creation function * fixing some issues * execution of data query * revert options changes * changed migration * fixed some migration issues: testing migration * multi env support * app import export fix * fixes * migration fixes * removed plugins from data query * fixing some migration issues * fixes * remove console log * fix * front end api changes * backward compatibility for app import * Fixed a bug * correcting some mistakes * Added constraints and fixed some issues * changes * fix for data source listing * fixing version operation issues * remove kind from data query * removed kind from data query * fixes * fixes * fix for version creation * migration fixes * Fixed preview and run query issues * Fix: new version and event query id issue * fixed rest api oauth issue - next test refresh token * import export changes * fixes for app import * import fix * added await for for loops * fix * fix for migration * Fixed backend oauth-envId issue * import export changes * migration fixes * fix * fix * fix for app import from 0.9.0 * test case fixes * test case fixes * making app name mandatory for import * adding type for options * fix: imported apps query linking issues * review changes * lint issue fixes * added on delete cascade Co-authored-by: Muhsin Shah <muhsinshah21@gmail.com>
2022-12-09 14:53:42 +00:00
const url = hasDataSource ? `${sourceOptions.url || ''}${queryOptions.url || ''}` : queryOptions.url;
2021-07-17 14:22:37 +00:00
const method = queryOptions['method'];
const json = method !== 'get' ? this.body(sourceOptions, queryOptions, hasDataSource) : undefined;
const paramsFromUrl = urrl.parse(url, true).query;
if (authType === 'bearer') {
headers['Authorization'] = `Bearer ${sourceOptions.bearer_token}`;
}
const requestOptions: OptionsOfTextResponseBody = {
method,
headers,
...this.fetchHttpsCertsForCustomCA(),
searchParams: {
...paramsFromUrl,
...this.searchParams(sourceOptions, queryOptions, hasDataSource),
},
...(isUrlEncoded ? { form: json } : { json }),
};
if (authType === 'basic') {
requestOptions.username = sourceOptions.username;
requestOptions.password = sourceOptions.password;
}
2021-07-17 14:22:37 +00:00
try {
const response = await got(url, requestOptions);
result = this.isJson(response.body) ? JSON.parse(response.body) : response.body;
requestObject = {
requestUrl: response.request.requestUrl,
method: response.request.options.method,
headers: response.request.options.headers,
params: urrl.parse(response.request.requestUrl, true).query,
};
responseObject = {
body: response.body,
statusCode: response.statusCode,
};
responseHeaders = response.headers;
2021-07-17 14:22:37 +00:00
} catch (error) {
console.error(
`Error while calling REST API end point. status code: ${error?.response?.statusCode} message: ${error?.response?.body}`
);
2021-07-17 14:22:37 +00:00
if (error instanceof HTTPError) {
2021-07-17 14:22:37 +00:00
result = {
requestObject: {
requestUrl: sourceOptions.password // Remove password from error object
? error.request.requestUrl?.replace(`${sourceOptions.password}@`, '<password>@')
: error.request.requestUrl,
requestHeaders: error.request.options.headers,
requestParams: urrl.parse(error.request.requestUrl, true).query,
},
responseObject: {
statusCode: error.response.statusCode,
responseBody: error.response.body,
},
responseHeaders: error.response.headers,
};
2021-07-17 14:22:37 +00:00
}
if (requiresOauth && error?.response?.statusCode == 401) {
throw new OAuthUnauthorizedClientError('Unauthorized status from API server', error.message, result);
}
2021-07-17 14:22:37 +00:00
throw new QueryError('Query could not be completed', error.message, result);
}
requestObject['headers'] = cleanSensitiveData(requestObject['headers'], ['authorization']);
2021-07-17 14:22:37 +00:00
return {
status: 'ok',
data: result,
request: requestObject,
response: responseObject,
responseHeaders,
};
2021-07-17 14:22:37 +00:00
}
fetchHttpsCertsForCustomCA() {
if (!process.env.NODE_EXTRA_CA_CERTS) return {};
return {
https: {
certificateAuthority: [...tls.rootCertificates, readFileSync(process.env.NODE_EXTRA_CA_CERTS)].join('\n'),
},
};
}
checkIfContentTypeIsURLenc(headers: [] = []) {
const objectHeaders = Object.fromEntries(headers);
const contentType = objectHeaders['content-type'] ?? objectHeaders['Content-Type'];
return contentType === 'application/x-www-form-urlencoded';
}
async refreshToken(sourceOptions: any, error: any, userId: string, isAppPublic: boolean) {
const isMultiAuthEnabled = sourceOptions['multiple_auth_enabled'];
const currentToken = getCurrentToken(isMultiAuthEnabled, sourceOptions['tokenData'], userId, isAppPublic);
const refreshToken = currentToken['refresh_token'];
if (!refreshToken) {
throw new QueryError('Refresh token not found', error.response, {});
}
const accessTokenUrl = sourceOptions['access_token_url'];
const clientId = sourceOptions['client_id'];
const clientSecret = sourceOptions['client_secret'];
const grantType = 'refresh_token';
const isUrlEncoded = this.checkIfContentTypeIsURLenc(sourceOptions['access_token_custom_headers']);
const customAccessTokenHeaders = sanitizeCustomParams(sourceOptions['access_token_custom_headers']);
const data = {
client_id: clientId,
client_secret: clientSecret,
grant_type: grantType,
refresh_token: refreshToken,
};
const accessTokenDetails = {};
let result, response;
try {
response = await got(accessTokenUrl, {
method: 'post',
headers: {
'Content-Type': isUrlEncoded ? 'application/x-www-form-urlencoded' : 'application/json',
...customAccessTokenHeaders,
},
form: isUrlEncoded ? data : undefined,
json: !isUrlEncoded ? data : undefined,
});
result = JSON.parse(response.body);
} catch (error) {
console.error(
`Error while REST API refresh token call. Status code : ${error.response?.statusCode}, Message : ${error.response?.body}`
);
if (error instanceof HTTPError) {
result = {
requestObject: {
requestUrl: error.request?.requestUrl,
requestHeaders: error.request?.options?.headers,
requestParams: urrl.parse(error.request?.requestUrl, true).query,
},
responseObject: {
statusCode: error.response?.statusCode,
responseBody: error.response?.body,
},
responseHeaders: error.response?.headers,
};
}
if (error.response?.statusCode >= 400 && error.response?.statusCode < 500) {
throw new OAuthUnauthorizedClientError(
'Unauthorized status from Oauth server',
JSON.stringify({ statusCode: error.response?.statusCode, message: error.response?.body }),
result
);
}
throw new QueryError(
'could not connect to Oauth server',
JSON.stringify({ statusCode: error.response?.statusCode, message: error.response?.body }),
result
);
}
if (!(response.statusCode >= 200 || response.statusCode < 300)) {
throw new QueryError(
'could not connect to Oauth server. status code',
JSON.stringify({ statusCode: response.statusCode }),
{
responseObject: {
statusCode: response.statusCode,
responseBody: response.body,
},
responseHeaders: response.headers,
}
);
}
if (result['access_token']) {
accessTokenDetails['access_token'] = result['access_token'];
accessTokenDetails['refresh_token'] = result['refresh_token'] || refreshToken;
} else {
throw new QueryError(
'access_token not found in the response',
{},
{
responseObject: {
statusCode: response.statusCode,
responseBody: response.body,
},
responseHeaders: response.headers,
}
);
}
return accessTokenDetails;
}
2021-07-17 14:22:37 +00:00
}