Linked Questions

Popular Questions

Can't get access_token with MSAL/React

Asked by At

I am trying to get an access token using MSAL and React using Azure B2C. I have configured B2C applications with permissions, scope, and setup a user flow, and I am able to login and get an id_token, but the AuthenticationResult never contains an access_token and is never set on subsequent requests.

enter image description here

After logging in, here is code to get an access_token:

export async function getAccessToken(){

    const account = msalInstance.getActiveAccount();
    const accessTokenRequest = {
        scopes: ["https://<my api uri>/api.full_access"],
        account: account,
    }
    var response = await msalInstance.acquireTokenSilent({
        accessTokenRequest,
        account: account
    });

    return response;
}

@azure/msal-browser = ^3.0.1 @azure/msal-react = 2.0.1

Related Questions