gpt4 book ai didi

azure - 为什么我的 Azure Active Directory 身份验证 token 不包含 MS Graph 的权限?

转载 作者:行者123 更新时间:2023-12-02 07:43:19 24 4
gpt4 key购买 nike

在开始编写应用程序代码之前,我在 Postman 工作,这样我就可以了解我实际上应该做什么 - 这是有教育意义的;在实际的应用程序开发中,我将使用 MSAL 进行身份验证。

与此同时,我什至无法获得有效的 token 。

我在 Azure 上的应用程序具有 Calendar.ReadCalendar.ReadWrite在 Azure 门户的 API 权限边栏选项卡中设置的权限。

我已经为应用程序创建了一个客户端 key (因此使用客户端凭据流程),并且我提供 /.default范围为 this accepted answer on MS docs .

当我尝试在 https://graph.microsoft.com/v1.0/users/<my user id>/events 查询 MS 图时我收到错误消息:

The token contains no permissions, or permissions can not be understood

果然,该 token 既不包含 scproles claim 。

我还引用了csharpcorner获取 token 以及 the actual documentation在 Postman 中配置请求。

我不明白我哪里错了。据我所知,我正在按照我应该做的方式做一切,但我只是没有取得任何进展。

我哪里出错了?我错过了什么吗?我是不是做错了什么?

这是我来自 Postman 的 jquery 代码:

var settings = {
"url": "https://login.microsoftonline.com/redacted/oauth2/token",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"data": {
"grant_type": "client_credentials",
"client_id": "redacted",
"client_secret": "redacted",
"resource": "https://graph.microsoft.com",
"scope": "./default"
}
};

$.ajax(settings).done(function (response) {
console.log(response);
});

非常感谢您的帮助。

提前致谢

最佳答案

好吧,这就是问题所在,您尚未授予 Calendars.ReadCalendars.ReadWrite 应用程序权限

因为您正在使用客户端凭据流来获取 token 并调用 /users/{user id} 端点来列出其他用户的事件。因此,您必须授予应用程序权限并授予该权限的管理员同意。那么你的问题就解决了。

enter image description here

关于azure - 为什么我的 Azure Active Directory 身份验证 token 不包含 MS Graph 的权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67811549/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com