MS Graph API - ManagedDevices obtaining Scope

流过昼夜 提交于 2019-12-11 05:54:46

问题


My goal is to create a schedulable PowerShell script that will report on recently enrolled devices. I have created the Application and granted some permissions.

 $OauthTokenEndpoint = 'https://login.microsoftonline.com/tenantid/oauth2/token'

$OauthRequest = @{
    grant_type="client_credentials"
    client_id = "clientidguid"
    client_secret = "clientidsecret"
    resource = "https://graph.microsoft.com"
    scope="DeviceManagementManagedDevices.Read.All"
}

$AuthResponse = Invoke-RestMethod -Uri $OauthTokenEndpoint -Method Post -ContentType application/x-www-form-urlencoded -Body $OauthRequest
$Token = $authresponse.access_token

#this query completes successfully
$Success = Invoke-restmethod -uri https://graph.microsoft.com/v1.0/users/username@domain.com/ownedDevices  -Headers @{Authorization = "Bearer $Token"}  -method Get

#this query fails with 401 unauthorised
$401Error = Invoke-RestMethod -Headers @{Authorization = "Bearer $Token"} -uri  "https://graph.microsoft.com/beta/managedDevices/deviceguid?`$select=hardwareInformation" -Method GET

I believe that my issue is that I have not, or can not grant DeviceManagementManagedDevices.Read.All scope permissions to my application. This API works with Graph Explorer, and I have an interactive version of this script that uses delegated permissions that works. How can I permit my Application to access the ManagedDevices API endpoint so that I can use it non-interactively.


回答1:


Received information from Microsoft that using Intune Graph APIs without user credentials is currently not supported.



来源:https://stackoverflow.com/questions/42497266/ms-graph-api-manageddevices-obtaining-scope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!