Trying to pass a msal react (msal browser) access token to msal node

Michael Garfinkel 1 Reputation point
2021-05-16T21:59:39.793+00:00

Trying to pass a msal react (msal browser) access token to an authenticated api to ensure that the user is authenticated and has access to that api. I have been using msal-node to try to validate the access tokens but cant seem to find the right method to make sure the access token is valid and pull the user's attributes to make sure it has the right attributes.

tried acquireTokenByCode but get The provided JWE is not a valid 5 segment token.

    const pca = new msal.ConfidentialClientApplication(publicClientConfig);
    const response = await pca.acquireTokenByCode({
        scopes: ['openid', '<client_id>'],
        redirectUri: '<redirect_url>',
        code: req.headers.token,
        authority: '<authority_url>'
    })

Any thoughts on how best to go about this?

using: msal-react v2, msal-node, user on azure ad b2c

Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,639 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,455 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Saurabh Sharma 23,671 Reputation points Microsoft Employee
    2021-05-17T22:47:32.677+00:00

    Hi @Michael Garfinkel ,

    Thanks for using Microsoft Q&A !!
    It looks like a scope issue. Instead of using client_id pass the URI of the web API scope like https://<your-tenant-name>.onmicrosoft.com/api/<scope>.

    Thanks
    Saurabh