[REQ][typescript-fetch] Accept promises for bearer token in fetch
Created by: minorai
Is your feature request related to a problem? Please describe.
I want to be able to supply access tokens to APIs from MSAL library which are acquired in asynchronous manner:
const response = await msalInstance.acquireTokenSilent({
...loginRequest,
account: account
})
Describe the solution you'd like
I want for configuration parameters to accept asynchronous function
export interface ConfigurationParameters {
// ....
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>); // parameter for oauth2 security
// ....
}
Describe alternatives you've considered
Where aren't any alternatives that I am aware of except for switching for another request framework or regenerating API objects on new tokens.
Additional context
This issue is identical to #7105 (closed) only for fetch instead of axios