【发布时间】:2018-07-26 04:17:17
【问题描述】:
我们希望能够通过 API 将应用上传到 Intune 商店。
我看到了this example on GitHub,并想在 JS 中做类似的事情,所以我尝试使用相同的 REST 调用。
问题是,我似乎无法正确发出 https://graph.microsoft.com/beta/deviceAppManagement/mobileApps 请求 - 我总是得到 401。通过 Graph API Explorer 发出相同的请求时,它工作正常。
我尝试修复我的权限,但我在获取正确的令牌时有点卡住了。 我在“公共”和我们自己的租户上使用管理员帐户执行了以下步骤:
已征得管理员同意 -
https://login.microsoftonline.com/nativeflow.onmicrosoft.com/adminconsent?client_id=<ID>&redirect_uri=<URI>获得用户授权 -
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=<ID>&response_type=code&redirect_uri=<URI>&response_mode=query&scope=DeviceManagementApps.ReadWrite.All-
获取实际令牌的 POST 请求 -
https://login.microsoftonline.com/nativeflow.onmicrosoft.com/oauth2/v2.0/token具有以下主体:
client_id: <ID> scope: https://graph.microsoft.com/.default client_secret: <secret> grant_type: client_credentials requested_token_use: on_behalf_of code: <The code I got in step 2>
我尝试将第 3 步中的范围更改为 https://graph.microsoft.com/DeviceManagementApps.ReadWrite.All 或简单地更改为 DeviceManagementApps.ReadWrite.All,但它说它不是有效范围。
我在第 3 步中获得了一个令牌,但是当我尝试调用实际 API 时收到此错误:
{
ErrorCode:"Forbidden",
Message:{
_version: 3,
Message: "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: 7b5c3841-976d-4509-b946-f7fdabd047d7 - Url: https://fef.msub02.manage.microsoft.com/StatelessAppMetadataFEService/deviceAppManagement/mobileApps?api-version=5018-05-02",
CustomApiErrorPhrase: "",
RetryAfter: null,
ErrorSourceService: "",
HttpHeaders: {"WWW-Authenticate":"Bearer realm=urn:intune:service,f0f3c450-59bf-4f0d-b1b2-0ef84ddfe3c7"}
},
Target:null,
Details:null,
InnerError:null,
InstanceAnnotations:[]
}
所以是的,我几乎被困住了。有没有人有这方面的经验?我试过用 Postman、curl 和 via code 进行调用,但没有任何效果。
干杯:)
【问题讨论】: