when accessing the api endpoint getting 404 after adding Authorize attribute office 365 login

Mohamed Umair Mohamed Anhar 41 Reputation points
2022-12-19T17:04:43.757+00:00

ProtectedRoutemap has been configured in the Angular application

272149-image.png

272212-image.png

272126-image.png

Microsoft Security Microsoft Entra Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 30,296 Reputation points Microsoft Employee Moderator
    2022-12-20T17:38:08.887+00:00

    Hi @Mohamed Umair Mohamed Anhar ,

    Thanks for reaching out.

    I understand you are trying to protect the API using authorize attribute and getting 404 error.

    This error usually comes when you are not providing valid access token. Did you try to decode your access token using jwt.ms have valid scopes?

    To call the API, MSAL configuration has protectedResourceMap to make sure that your code adds the web API URI and the web API HTTP method, with the corresponding scopes. This configuration makes sure that MsalGuard is applied when Angular app tries to call the web API.

    protectedResourceMap: new Map([  
          [protectedResources.testApi.endpoint, protectedResources.testAPI.scopes]  
    

    Reference: https://learn.microsoft.com/en-us/azure/active-directory-b2c/enable-authentication-angular-spa-app#call-a-web-api

    Hope this will help.

    Thanks,
    Shweta

    --------------------------

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

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.