Issue with MSAL Interceptor #3027
Unanswered
dmccolloughOneGas
asked this question in
Help
Replies: 1 comment
-
nevermind, looks like I had a typo somewhere. I have it working now. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm having a issue with the MSAL interceptor not automatically adding the token to the outgoing http request.
I have one call working to a different endpoint on a different component, but now that I'm trying to expand it to a different component it's not working.
I have one component, let's call it 'Home'.
The second component, is called 'Goodcatch'
You get to the second component by clicking on a button on the Home component. The home component html is using a routerlink to navigate to the Goodcatch component.
The Goodcatch component is calling a angular service that constructs the http request and makes a post statement to the correct endpoint on our API.
I'm debugging using Chrome and I can see the request being made on the network tab and then I get a 401 - Unauthorized, Why is this not WORKING???????
On a previous request on the Home component it works fine, I can grab the token that it used and using postman, make a post request to the endpoint that the good catch endpoint and that will work fine.
Here is the auth-config.json file where I define my ClientId, TenantId, and the resource endpoints with their scopes.
Please note, I have change the server names, controller names and method names to be not so identifying.
{
"credentials": {
"clientId": "617a6feb-386a-4395-8059-880e430e3329",
"tenantId": "1cac1176-089b-4bcd-aa37-24195cff538e"
},
"configuration": {
"redirectUri": "http://localhost:4200",
"postLogoutRedirectUri": "http://localhost:4200"
},
"resources": {
"onetAPI": {
"resourceUri": "https://servername/api/junk/somemethod",
"resourceScopes": [ "api://ca026bc3-0e37-4526-8ddd-8eea8b64b09b/access_as_user" ]
},
"SubmitIssue": {
"resourceUri": "https://servername/api/junk1/anothermethod",
"resourceScopes": [ "api://ca026bc3-0e37-4526-8ddd-8eea8b64b09b/access_as_user" ]
},
"graph": {
"resourceUri": "https://graph.microsoft.com/v1.0/me",
"resourceScopes": ["user.read"]
}
}
}
In my app.module file, I have the following to setup the MSALInterceptorConfigFactory
First I import the auth-config.json file
import * as auth from './auth-config.json';
In my app-routing.module.ts file, I have the routes identified with the MsalGuard.
const appRoutes: Routes = [
{ path: 'home', component: HomeComponent,
canActivate: [
MsalGuard
]
},
{
path: 'goodcatch', component: GoodcatchComponent,
canActivate: [
MsalGuard
]
},
{ path: '', component: InitComponent},
]
Beta Was this translation helpful? Give feedback.
All reactions