在Swaggerui上配置授权代码,以供Azuread身份验证/授权配置
我正在尝试使用Swaggerui的Azuread授权使用.NET CORE基于API项目的Azuread的授权代码赠款流,但我要低于错误,
错误:未经授权:错误,错误:Invalid_client,Description,Description:Aadsts700025:aadsts700025:客户端都不是公共的,所以''''' client_assertion'nor'client_secret'应该出现。
尽管我的客户端不是公开的,即使我验证了app-manifest,它具有“ lasterpublicclient”:false。
Azuread上的设置
- hostapp
- 客户端appp
hostapp暴露了示波器,并且在应用程序权限下将其添加到clientapp中。
ClientApp在我使用授权代码赠款类型时,在Spa下添加了Swagger的Redirect-uri。
注意:而无需提供秘密,我能够进行身份验证,但我想将秘密强制执行。
其他有关的用户也报告了下面发布的其他用户,但答案尚不清楚,即使它已经接受了答案。
”>正确地配置ASP.NET Core 5 Swagger与Azure A/D授权代码身份验证一起使用?
编辑:
我在Web中添加了SPA和Postman Redirect URL中添加了Swagger Retirect URL。
I am trying to authorize using Authorization Code grant flow for AzureAD from SwaggerUI for my .net core based API project but I am getting below error,
Error: Unauthorized, error: invalid_client, description: AADSTS700025: Client is public so neither 'client_assertion' nor 'client_secret' should be presented.
Though my Client is not public, even I verified app-manifest, it has "allowPublicClient": false.
Setup Over AzureAD
- HostAPP
- ClientAPP
HostAPP has scopes exposed and same are added to ClientAPP under App Permissions.
ClientAPP has redirect-uri of swagger added under SPA as I am using authorization code grant type.
Note: Without supplying secret, I am able to authenticate but I want to make secret mandatory.
Same is reported by other user in question posted below but the answer is not clear yet even though it has accepted answer.
Edit:
I have Swagger redirect URL added in SPA and Postman redirect URL in Web.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我试图在环境中复制相同的结果,并获得了以下结果:
我在Azure AD中注册的应用程序,并添加了
重定向uri
在水疗中:当我尝试生成访问令牌时,我得到了如下所示的同样错误:
解决错误,我添加了重定向URI在Web下删除水疗中心并按照以下方式保存:
修改更改后,再次获取授权代码并生成访问令牌如下:
因此,尝试删除 swagger重定向url spa ,并在 web 下将其添加到成功的访问令牌下,如此 强> Carl Zhao 。
I tried to reproduce the same in my environment and got the results like below:
I registered application in Azure AD and added
redirect URI
under SPA:When I tried to generate the access token, I got the same error like below:
To resolve the error, I added the redirect URI under Web by deleting the SPA and Save like below:
After modifying the changes, get the authorization code again and generate the access token like below:
So, try deleting the Swagger Redirect URL in SPA and add it under Web to get access token successfully as suggested in this SO Thread by Carl Zhao.