question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTTP interceptor for localhost api

See original GitHub issue

Source

  • Customer request

Library

  • @azure/msal-browser@2.12.0
  • @azure/msal-angular@2.0.0-beta.0

Framework

  • Angular

Description

I’m trying to call an localhost API and to attach bearer token on the header. For now I have added the localhost api route to the protectedResourceMap but there is no bearer token inside the header. Tried to add jsonplaceholder to make an http post call to it and it works. The only issue is when I try to make http call to localhost api.

protectedResourceMap.set('http://localhost:5000/add/',  ['user.read']);

Screenshot_4

Error Message

No error, just no bearer token in the header section

MSAL Configuration

I'm using AD for authentication.

Reproduction steps

The URL is registered in the MsalInterceptorConfiguration:

protectedResourceMap.set(‘http://localhost:5000/add/’, [ [‘api://consent-id’] ]);

localhost:5000 is registered in Redirect URIs of Azure portal

I'm using MsalInterceptor which is registered in the app.module.ts provider array.

Expected behavior

To have bearer token in the header section

Identity Provider

  • Azure AD

Browsers/Environment

  • Chrome

Regression

  • Did this behavior work before? Version: NaN

Security

  • Is this issue security related?

Source

  • Customer request

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

2reactions
jo-arroyocommented, Mar 10, 2021

@nicholashendrickx-tomtom It looks like you may be referencing the @azure/msal-angular@1 docs. Please see our updated initialization and configuration docs for the new shape of the protectedResourceMap, as well as the upgrade guide for more information about protected resources in MSAL Angular v2.

1reaction
VladBozhinovskicommented, Mar 17, 2021

@nicholashendrickx-tomtom that’s good to hear that it helped buddy 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Msal Angular HTTP interceptor for localhost not attaching token
I'm trying to call a localhost API and to attach the bearer token on the header. It should be done by msal-angular automatically....
Read more >
Manage HTTP Requests In Angular: Http Interceptor - C# Corner
The interceptor allows you to intercept the outgoing and incoming HTTP request handle using HttpClient service. It is capable to change HTTP ......
Read more >
Issue with HttpInterceptor default url and localhost #1041
Current behavior When i test in my machine with http://localhost:4200/ as the HttpInterceptor default url, everything is working fine.
Read more >
How to build an Http Interceptor in Angular Framework - Medium
To avoid this problem we are going to use Http interceptor which is a new feature included in Angular that help us to...
Read more >
Making API call bypassing Interceptor if one is configured in ...
a dev server. Navigate to `http:/ /localhost:4200/`.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found