how to verify azure access token using Nodejs ?

MarwanSamrout-7915 40 Reputation points

i have downloaded angular sample microsoft-authentication-library-for-js\samples\msal-angular-v3-samples\angular16-sample-app from github and im trying to make a backend to protect my routes using azure ad
in angular im getting access token using this function

        scopes: ['']
        next: (result) => {
            console.log('Access Token:', result.accessToken);
        error: (error) => {
            console.error('Error acquiring token:', error);

now when my angular app try to call nodejs server i want to verify that token, how can i do that with best practices? and thank you.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
18,693 questions
0 comments No comments
{count} votes

Accepted answer
  1. Shweta Mathur 25,466 Reputation points Microsoft Employee

    Hi @Marwan Samrout , Thaks for reaching out. To verify the access token received from the client-side in your Node.js server, you can use the passport-azure-ad library. This library provides a middleware that can be used to authenticate the incoming requests based on the access token.

    Hope this will help.


    Please remember to "Accept Answer" if answer helped you.

0 additional answers

Sort by: Most helpful