angular - 如何配置 msal-angular 拦截器以将访问令牌 (v2) 发送到自己的域 (self)
问题描述
我从 v1 更新到 @azure/msal-angular v2。而且我不知道如何配置它以将访问令牌发送到托管在同一域上的后端。
因此,当我的前端发出请求时/api/foo
,MsalInterceptor
应该以版本 2 格式(而不是版本 1)附加我的访问令牌。
这使其发送版本 1 访问令牌
const msalInterceptorConfig: MsalInterceptorConfiguration = {
interactionType: InteractionType.Redirect,
protectedResourceMap: new Map([
['/', ['openid']],
]),
};
我设法通过添加来“欺骗”它
const msalInterceptorConfig: MsalInterceptorConfiguration = {
interactionType: InteractionType.Redirect,
protectedResourceMap: new Map([
['/', [`api://${clientId}/access_as_user`]],
]),
};
但随后 AzureAD 开始抱怨
AADSTS90009:应用程序正在为自己请求令牌。仅当使用基于 GUID 的应用标识符指定资源时才支持此方案
所以这不是一个选择。如何MsalInterceptor
将版本 2 访问令牌发送到/
?
解决方案
我不知道这是否是正确的方式,甚至是预期的行为。但是以下配置将 v2 访问令牌发送到我的后端。
const msalInterceptorConfig: MsalInterceptorConfiguration = {
interactionType: InteractionType.Redirect,
protectedResourceMap: new Map([
['/', [`${clientId}/openid`]],
]),
};
推荐阅读
- javascript - 如何使用 Dropzone.js 向您显示已存储在服务器上的文件扩展名 image/*、application/pdf、mp4
- javascript - Nextjs 用于 xml 站点地图的动态路由
- excel - 为 FSO 的固定路径分配变量以扫描文件夹和子文件夹
- google-trends - 为什么谷歌趋势数据在不同的两天下载时不一致?
- javascript - 如何在 Pug 表单中添加过滤器?
- java - Java:如何修复多种方法中的代码重复?
- javascript - 猫鼬将数组添加到子文档
- powerbi - 取消选中当前页面书签设置的结果是什么?
- javascript - 无法在 AWS EC2 中读取未定义的属性(正在读取 'getusermedia' )
- amazon-web-services - 尽管 SAM 模板中提到了 S3 存储桶,但为什么没有创建它?