我正在使用msal-angular进行Azure aad身份验证。现在,当我调用Web API(用C#编写)时,我将获得未经授权的访问401。
预期的行为:
用令牌调用API后,请求应该会成功并进入网络API。
MSAL角版本:“ @ azure / msal角”:“ ^ 0.1.2”
下面是我的app.module.ts
export const protectedResourceMap:[string, string[]][]=[ ['http://localhost:8133/api/FrameworkData/ReleaseManagement/GetAllFrameworkDetails/',['api://d6d2dc96-6757-47f7-83bd-2212e5e9099d/access_as_user']] ];
MsalModule.forRoot({
clientID: 'b8b72473-3f78-4f5d-bf08-8a2e2a3d135e',//'6226576d-37e9-49eb-b201-ec1eeb0029b6',
authority: "https://login.microsoftonline.com/26fa1297-1ee6-412a-a80a-cebf476ec6ad/",
validateAuthority: true,
redirectUri: "http://localhost:4200/",
cacheLocation : "localStorage",
//loadFrameTimeout:10000,
postLogoutRedirectUri: "http://localhost:4200/",
navigateToLoginRequestUrl: true,
popUp: false,
consentScopes: ["user.read", 'api://d6d2dc96-6757-47f7-83bd-2212e5e9099d/access_as_user'], //"api://a88bb933-319c-41b5-9f04-eff36d985612/access_as_user"
unprotectedResources: ["https://www.microsoft.com/en-us/"],
protectedResourceMap: protectedResourceMap,
logger: loggerCallback,
correlationId: '1234',
level: LogLevel.Info,
piiLoggingEnabled: true
}
实际问题令牌已生成,并且正在作为承载在请求标头中发送。 GET http://localhost:8133/api/FrameworkData/ReleaseManagement/GetAllFrameworkDetails/ 401(未经授权)