Skip to content

[REQ][typescript-fetch] Accept promises for bearer token in fetch #9658

@minorai

Description

@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 only for fetch instead of axios

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions