无法在Postman中身份验证Azure AD功能应用程序

发布于 2025-02-14 00:08:47 字数 972 浏览 0 评论 0原文

我已启用了函数应用程序的Azure AD。 AzureIdentity是我的功能应用程序名称。 我正在使用“ \ oauth2 \ token”

Get:
https://login.microsoftonline.com/{my tenant ID}/oauth2/token

Headers: Content-Type: application/x-www-form-urlencoded
Body:

grant_type:client_credentials
resource:https://management.azure.com/
client_id:04e17699-64cd-42ec-96ec-23be345ef6ed
client_secret:{My secret}

”获取身份验证邮递员” 我在get request上获得了携带者令牌并将其传递给功能,但是我遇到了401个身份验证错误,如下所示。不知道我在哪里做错了。

请帮助我如何验证该功能,谢谢。

I have enabled Azure AD for the function APP. AzureIdentity is my Function APP name.
Azure Function
I am using "\oauth2\token"

Get:
https://login.microsoftonline.com/{my tenant ID}/oauth2/token

Headers: Content-Type: application/x-www-form-urlencoded
Body:

grant_type:client_credentials
resource:https://management.azure.com/
client_id:04e17699-64cd-42ec-96ec-23be345ef6ed
client_secret:{My secret}

Get Authentication PostMan
I am getting bearer token on Get request and passing it to the Function, but I am getting 401 Authentication error as below. Not sure where I am doing wrong.
Function APP

Please help how can I authenticate the function, Thank you.

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

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

发布评论

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

评论(2

怎言笑 2025-02-21 00:08:47

不需要“资源”参数,而是使用“范围”参数

范围,这是我的自定义应用ID,其定义了自定义应用程序角色。

范围==> “ 04E17699-64CD-42EC-96EC-23BE345EF6ED/.DEFAULT”

“在此处输入图像说明”

'resource' parameter is not required, instead use 'scope' parameter

Scope here is my custom app ID which has a custom application role defined.

scope ==> "04e17699-64cd-42ec-96ec-23be345ef6ed/.default"

enter image description here

enter image description here

镜花水月 2025-02-21 00:08:47

我试图在环境中重现相同的错误,并获得了与以下相同的错误:

“在此处输入图像描述”
要解决错误,请使用v2 endpoint来生成以下令牌:

“在此处输入图像描述”

使用上述生成的访问令牌,我能够成功地调用函数应用程序,如下所示:

“在此处输入图像说明”

确保给出 code 您在功能url中作为x-function-key 参数。

I tried to reproduce the same in my environment and got the same error as below:

enter image description here
To resolve the error, make use of V2 endpoint to generate the token like below:

enter image description here

Using the above generated access token, I am able to call the Function app successfully like below:

enter image description here

Make sure to give the code you get in function URL as a value to x-function-key parameter.

enter image description here

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