Intune设备管理图API

发布于 2025-01-20 15:12:41 字数 1678 浏览 1 评论 0 原文

有谁知道如何使用带有访问/刷新令牌的 MS Graph 连接到 Intune API?

我正在使用 AADInternals 模块。

Get-AccessTokenWithRefreshToken -Resource "https://graph.microsoft.com" -ClientId "00000000-0000-0000-0000-000000000000" -RefreshToken $refreshtoken -TenantId $Tenant

我已经尝试了所有类型的资源和 clientid,但是当我拨打电话时,我不断收到如下错误:

{"error":"invalid_grant","error_description":"AADSTS70000: Provided grant is invalid or malformed.\r\n"

{"error":"invalid_grant","error_description":"AADSTS9002313: Invalid request. Request is malformed or invalid"

{"error":"unauthorized_client","error_description":"AADSTS700038: 00000000-0000-0000-0000-000000000000

或者当我使用默认的 MSGraph API clientid &资源:

$apiUrl = "https://graph.microsoft.com/v1.0/deviceManagement/managedDeviceOverview"

Invoke-RestMethod -Headers @{Authorization = "Bearer " + $attributes.MSGraph} -Uri $apiUrl -Method GET -ContentType 'application/json'

Invoke-RestMethod : The remote server returned an error: (403) Forbidden.

或:

Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

更新 1

DeviceCompliance 似乎正在工作,我只是无法让 ManagedDeviceOverview 工作......即使在 Graph Explorer Developer 中也会出现错误......

https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies https://graph.microsoft.com/v1.0/deviceManagement/managedDeviceOverview"

Does anyone know how I can connect to the Intune API using MS Graph with a Access/Refresh token?

I'm using AADInternals module.

Get-AccessTokenWithRefreshToken -Resource "https://graph.microsoft.com" -ClientId "00000000-0000-0000-0000-000000000000" -RefreshToken $refreshtoken -TenantId $Tenant

I've tried all kind of resources and clientid, but when I make a call I keep getting errors like:

{"error":"invalid_grant","error_description":"AADSTS70000: Provided grant is invalid or malformed.\r\n"

{"error":"invalid_grant","error_description":"AADSTS9002313: Invalid request. Request is malformed or invalid"

{"error":"unauthorized_client","error_description":"AADSTS700038: 00000000-0000-0000-0000-000000000000

Or when I use a default MSGraph API clientid & resource:

$apiUrl = "https://graph.microsoft.com/v1.0/deviceManagement/managedDeviceOverview"

Invoke-RestMethod -Headers @{Authorization = "Bearer " + $attributes.MSGraph} -Uri $apiUrl -Method GET -ContentType 'application/json'

Invoke-RestMethod : The remote server returned an error: (403) Forbidden.

or:

Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

Update 1

DeviceCompliance seems to be working, I just can't get managedDeviceOverview to work.... Even in Graph Explorer Developer it's giving errors...

https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies
https://graph.microsoft.com/v1.0/deviceManagement/managedDeviceOverview"

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

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

发布评论

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

评论(1

臻嫒无言 2025-01-27 15:12:41

如果 /deviceManagement/deviceCompliancePolicies 正在工作,而 /deviceManagement/managedDeviceOverview 则不工作,我的猜测是 AAD 中的企业应用程序(具有您的 clientid 的应用程序)缺少权限。传递到 Get-AccessTokenWithRefreshToken 中的 -ClientId 参数)。

/deviceManagement/deviceCompliancePolicies 的权限

DeviceManagementConfiguration.Read.All、DeviceManagementConfiguration.ReadWrite.All

这些权限可能已设置(因为 api 调用正在运行)。

检查此链接(章节先决条件):https://learn.microsoft.com/en-us/graph/api/intune-deviceconfig-devicecompliancepolicy-get?view=graph-rest-1.0#preventions

的权限/deviceManagement/managedDeviceOverview

DeviceManagementManagedDevices.Read.All、DeviceManagementManagedDevices.ReadWrite.All

可能未设置这些权限(因为 api 调用不 在职的)。

检查此链接(章节先决条件):https://learn.microsoft.com/en-us/graph/api/intune-devices-managementdeviceoverview-get?view=graph-rest-1.0#preventions

检查权限Azure 门户: Azure Active Directory -->企业应用-->您的企业应用程序(具有正确的 clientid)-->权限

If /deviceManagement/deviceCompliancePolicies is working and /deviceManagement/managedDeviceOverview is not, my guess is that there are permissions missing on the enterprise application in AAD (application with the clientid which you pass to the -ClientId parameter in Get-AccessTokenWithRefreshToken).

Permissions for /deviceManagement/deviceCompliancePolicies

DeviceManagementConfiguration.Read.All, DeviceManagementConfiguration.ReadWrite.All

These permissions might already be set (because the api call is working).

Check this link (chapter prerequisites): https://learn.microsoft.com/en-us/graph/api/intune-deviceconfig-devicecompliancepolicy-get?view=graph-rest-1.0#prerequisites

Permissions for /deviceManagement/managedDeviceOverview

DeviceManagementManagedDevices.Read.All, DeviceManagementManagedDevices.ReadWrite.All

These permissions might not be set (because the api call is not working).

Check this link (chapter prerequisites): https://learn.microsoft.com/en-us/graph/api/intune-devices-manageddeviceoverview-get?view=graph-rest-1.0#prerequisites

Check the permissions in the Azure portal: Azure Active Directory --> Enterprise applications --> Your enterprise app (with the right clientid) --> Permissions

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