在Swaggerui上配置授权代码,以供Azuread身份验证/授权配置

发布于 2025-02-09 18:23:15 字数 1105 浏览 1 评论 0原文

我正在尝试使用Swaggerui的Azuread授权使用.NET CORE基于API项目的Azuread的授权代码赠款流,但我要低于错误,

错误:未经授权:错误,错误:Invalid_client,Description,Description:Aadsts700025:aadsts700025:客户端都不是公共的,所以''''' client_assertion'nor'client_secret'应该出现。

尽管我的客户端不是公开的,即使我验证了app-manifest,它具有“ lasterpublicclient”:false。

Azuread上的设置

  1. hostapp
  2. 客户端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

  1. HostAPP
  2. 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.

How to correctly configure ASP.NET Core 5 Swagger to work with Azure A/D authorization code authentication?

Edit:

I have Swagger redirect URL added in SPA and Postman redirect URL in Web.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

靖瑶 2025-02-16 18:23:15

我试图在环境中复制相同的结果,并获得了以下结果:

我在Azure AD中注册的应用程序,并添加了 重定向uri 在水疗中:

“在此处intraimy

当我尝试生成访问令牌时,我得到了如下所示的同样错误:

“在此处inter

解决错误,我添加了重定向URI在Web下删除水疗中心并按照以下方式保存:

“在此处inter

修改更改后,再次获取授权代码并生成访问令牌如下:

“在此处输入图像说明”

因此,尝试删除 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:

enter image description here

When I tried to generate the access token, I got the same error like below:

enter image description here

To resolve the error, I added the redirect URI under Web by deleting the SPA and Save like below:

enter image description here

After modifying the changes, get the authorization code again and generate the access token like below:

enter image description here

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文