gpt4 book ai didi

node.js - 使用 Microsoft Graph 在 Teams 中创建 session 时出现 "Forbidden"错误

转载 作者:行者123 更新时间:2023-12-03 06:08:07 25 4
gpt4 key购买 nike

我想使用 API 创建 session 。我使用此权限在 Azure 门户中创建了一个应用程序:

OnlineMeetings.ReadWrite

接下来,我按照 OAuth 流程获取了访问 token (我删除了对 token 的部分访问权限并复制到此处):

{
"aud": "00000003-0000-0000-c000-000000000000",
"iss": "https://sts.windows.net/bbf86088-73dc-4587-89d3-33e6f9a1484f/",
"name": "Meet master account",
"oid": "90ac29be-2d4f-4e9b-a13c-b5abf8534cef",
"platf": "5",
"puid": "10032002F2311268",
"scp": "OnlineMeetings.ReadWrite User.Read profile openid email",
"signin_state": [
"kmsi"
],
"sub": "KfOfRbaUEccxbfM5KfcWDjzX1gRtijFJ7Qgqw09oslU",
"tenant_region_scope": "NA",
"tid": "bbf86088-73dc-4587-89d3-33e6f9a1484f",
"uti": "nQXEiowwn0SGCHPDY0IhAA",
"ver": "1.0",
}

之后,我提出了这样的请求:

POST https://graph.microsoft.com/v1.0/me/onlineMeetings
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

{
"startDateTime":"2022-01-01T14:30:34.2444915-07:00",
"endDateTime":"2022-01-01T15:00:34.2464912-07:00",
"subject":"Test Meeting"
}

我收到了这样的回复:

{
"error": {
"code": "Forbidden",
"message": "An error has occurred.",
"innerError": {
"date": "2023-09-14T09:32:46",
"request-id": "39c6117b-7f71-43d2-bc73-c21893c0d120",
"client-request-id": "39c6117b-7f71-43d2-bc73-c21893c0d120"
}
}
}

我不确定为什么会出现此错误。

最佳答案

The error usually occurs if you are trying to create online meeting with guest user or user from tenant with no Microsoft Teams license in it.

我创建了一个新租户,并通过授予 API 权限注册了一个 Azure AD 应用程序,如下所示:

enter image description here

现在,我通过 Postman 使用授权代码流生成了访问 token ,如下所示:

POST https://login.microsoftonline.com/<tenantID>/oauth2/v2.0/token

grant_type:authorization_code
client_id: <appID>
client_secret: <secret>
scope: OnlineMeetings.ReadWrite
code:code
redirect_uri:https://jwt.ms

回应:

enter image description here

为了检查 scpupn 声明,我在 jwt.ms 中解码了上述访问 token 网站如下:

enter image description here

当我使用此 token 创建在线 session 时,我也遇到相同的错误,因为租户没有没有有效许可证:

POST https://graph.microsoft.com/v1.0/me/onlineMeetings
Authorization: Bearer <token>
Content-Type: application/json

{
"startDateTime":"2022-01-01T14:30:34.2444915-07:00",
"endDateTime":"2022-01-01T15:00:34.2464912-07:00",
"subject":"Test Meeting"
}

回应:

enter image description here

To resolve the error, make sure to have at least one Office 365license in your tenant that includes Microsoft Teams in it.

当我对拥有适当许可证的租户进行相同的尝试时,在线 session 已成功创建,响应如下:

POST https://graph.microsoft.com/v1.0/me/onlineMeetings
Authorization: Bearer <token>
Content-Type: application/json

{
"startDateTime":"2022-01-01T14:30:34.2444915-07:00",
"endDateTime":"2022-01-01T15:00:34.2464912-07:00",
"subject":"Test Meeting"
}

回应:

enter image description here

关于node.js - 使用 Microsoft Graph 在 Teams 中创建 session 时出现 "Forbidden"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77103845/

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