Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface ConfigurationParameters {
clientId?: string;
clientSecret?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
accessTokenUrl?: string;
awsv4?: AWSv4Configuration;
basePath?: string;
serverIndex?: number;
Expand Down Expand Up @@ -67,6 +68,10 @@ export class Configuration {
* @param scopes oauth2 scope
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* oauth2 token url
*/
accessTokenUrl?: string;
/**
* temporary access token storage
*/
Expand Down Expand Up @@ -115,6 +120,7 @@ export class Configuration {
this.clientSecret = param.clientSecret;
this.tempAccessToken;
this.tempAccessTokenExpiration;
this.accessTokenUrl = param.accessTokenUrl ?? 'https://api.bandwidth.com/api/v1/oauth2/token';
this.accessToken = param.accessToken ?? (async (name, scopes) => {
const now = Math.floor(Date.now() / 1000);
if (this.tempAccessToken && (!this.tempAccessTokenExpiration || this.tempAccessTokenExpiration > now + 60)) {
Expand All @@ -125,7 +131,7 @@ export class Configuration {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
auth: { username: this.clientId || '', password: this.clientSecret || '' },
data: 'grant_type=client_credentials',
url: 'https://api.bandwidth.com/api/v1/oauth2/token'
url: this.accessTokenUrl
};
const response = await globalAxios.request(tokenRequestArgs);
this.tempAccessToken = response.data.access_token;
Expand Down
8 changes: 7 additions & 1 deletion custom_templates/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ConfigurationParameters {
clientId?: string;
clientSecret?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
accessTokenUrl?: string;
awsv4?: AWSv4Configuration;
basePath?: string;
serverIndex?: number;
Expand Down Expand Up @@ -57,6 +58,10 @@ export class Configuration {
* @param scopes oauth2 scope
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* oauth2 token url
*/
accessTokenUrl?: string;
/**
* temporary access token storage
*/
Expand Down Expand Up @@ -105,6 +110,7 @@ export class Configuration {
this.clientSecret = param.clientSecret;
this.tempAccessToken;
this.tempAccessTokenExpiration;
this.accessTokenUrl = param.accessTokenUrl ?? 'https://api.bandwidth.com/api/v1/oauth2/token';
this.accessToken = param.accessToken ?? (async (name, scopes) => {
const now = Math.floor(Date.now() / 1000);
if (this.tempAccessToken && (!this.tempAccessTokenExpiration || this.tempAccessTokenExpiration > now + 60)) {
Expand All @@ -115,7 +121,7 @@ export class Configuration {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
auth: { username: this.clientId || '', password: this.clientSecret || '' },
data: 'grant_type=client_credentials',
url: 'https://api.bandwidth.com/api/v1/oauth2/token'
url: this.accessTokenUrl
};
const response = await globalAxios.request(tokenRequestArgs);
this.tempAccessToken = response.data.access_token;
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/calls-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {

describe('CallsApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const callsApi = new CallsApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/conferences-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {

describe('ConferencesApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const conferencesApi = new ConferencesApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/endpoints-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {

describe('EndpointsApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const endpointsApi = new EndpointsApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/media-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Configuration } from '../../../configuration';

describe('MediaApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const mediaApi = new MediaApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/messages-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {

describe('MessagesApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const messagesApi = new MessagesApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/mfaapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { CodeRequest, VerifyCodeRequest } from '../../../models';

describe('MFAApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const mfaApi = new MFAApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/multi-channel-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {

describe('MultiChannelApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const multiChannelApi = new MultiChannelApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/phone-number-lookup-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {

describe('PhoneNumberLookupApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const phoneNumberLookupApi = new PhoneNumberLookupApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/recordings-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {

describe('RecordingsApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const recordingsApi = new RecordingsApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/statistics-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { Configuration } from '../../../configuration';

describe('StatisticsApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const statisticsApi = new StatisticsApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/toll-free-verification-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {

describe('TollFreeVerificationApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const tfvApi = new TollFreeVerificationApi(config);
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/api/transcriptions-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { CallTranscriptionDetectedLanguageEnum, CallTranscriptionTrackEnum } fro

describe('TranscriptionsApi', () => {
const config = new Configuration({
username: BW_USERNAME,
password: BW_PASSWORD,
accessToken: 'abcd1234',
basePath: 'http://127.0.0.1:4010'
});
const transcriptionsApi = new TranscriptionsApi(config);
Expand Down