Skip to content

Commit

Permalink
Use provided axios instance for credentials refresh operations (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris authored Jan 8, 2025
2 parents 006b5c4 + 691afea commit 24f8188
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class BaseAPI {
}
this.configuration.isValid();

this.credentials = Credentials.init(this.configuration);
this.credentials = Credentials.init(this.configuration, this.axios);

if (!this.axios) {
const httpAgent = new http.Agent({ keepAlive: true });
Expand Down
10 changes: 5 additions & 5 deletions credentials/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export class Credentials {
private accessToken?: string;
private accessTokenExpiryDate?: Date;

public static init(configuration: { credentials: AuthCredentialsConfig, telemetry: TelemetryConfiguration, baseOptions?: any }): Credentials {
return new Credentials(configuration.credentials, globalAxios, configuration.telemetry, configuration.baseOptions);
}
public static init(configuration: { credentials: AuthCredentialsConfig, telemetry: TelemetryConfiguration, baseOptions?: any }, axios: AxiosInstance = globalAxios): Credentials {
return new Credentials(configuration.credentials, axios, configuration.telemetry, configuration.baseOptions);
}

public constructor(private authConfig: AuthCredentialsConfig, private axios: AxiosInstance = globalAxios, private telemetryConfig: TelemetryConfiguration, private baseOptions?: any) {
this.initConfig();
Expand Down Expand Up @@ -155,7 +155,7 @@ export class Credentials {
}, {
maxRetry: 3,
minWaitInMs: 100,
}, globalAxios);
}, this.axios);

const response = wrappedResponse?.response;
if (response) {
Expand All @@ -180,7 +180,7 @@ export class Credentials {

attributes = TelemetryAttributes.fromResponse({
response,
attributes,
attributes,
});

attributes = TelemetryAttributes.prepare(attributes, this.telemetryConfig.metrics?.counterCredentialsRequest?.attributes);
Expand Down

0 comments on commit 24f8188

Please sign in to comment.