AddmicrosoftIdentityWebapi .NET Core 5 Web API?此支持版本V1和V2 API会吗? MSAL
我使用Adal.js和我的前端进行反应,并使用我的后端 MSAL ###以下是代码
服务 。
我如何支持这种情况?
因为我想强加我的后端了解v1 doken,而v1 doken是由front app adal.js创建的
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,可以根据要求请求V1访问令牌甚至V2。 。
但是,请检查API所需的标志:
端点您将获得V2 ID令牌。
发布给应用程序的访问令牌类型(V1或V2)由资源API的申请注册确定。
您可以确定您的API的配置为哪种类型的令牌,以接受进行较小的更改或查看App注册中的内容。在门户网站,当您转到“清单”部分时,请检查“ AccessTokenAcceptedversion” 。如果将其设置为null或1,则所有请求访问令牌来调用此资源的客户端应用程序将获得V1访问令牌( ,无论他们使用MSAL或ADAL是否请求访问令牌 < /em>)。
您可能需要要求使用/.default 范围: https://database.windows.net//.default
v1.0应用程序(msal)(msal)|微软文档
参考: authentication-是否可以获得Azure AD V1令牌使用MSAL? - 堆叠溢出
Yes, it is possible to request an V1 access token and even V2 depending on the requirement. .
But please check which token the API needs as:
endpoint you get a V2 ID token.
The access token type (v1 or v2) which is issued to your app is determined by the application registration of the resource API.
You can determine which type of tokens your API is configured to accept making small change or seeing what is present in app registration. In portal,when you go to the "Manifest" section, and check for "accessTokenAcceptedVersion". If it is set to null or 1, then all client applications requesting access tokens to call this resource will get a v1 access token (Regardless if they use MSAL or ADAL to request the access token).

And you may need to request a scope with /.default for example: https://database.windows.net//.default
According to Scopes for v1.0 apps (MSAL) | Microsoft Docs
Reference : authentication - Is it possible to obtain an Azure AD V1 token using MSAL? - Stack Overflow