我正在尝试创建 intune 应用保护策略。我尝试使用以下 API 来执行此操作,但都不起作用: POST /managedAppPolicies/ - 创建托管策略时(适用于 iOS 和 Android) - 返回 401 Unauthorized。
示例创建托管应用程序策略请求:
POST /managedAppPolicies/
Request Body :
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#managedAppPolicies/$entity",
"@odata.type": "#microsoft.graph.iosManagedAppProtection",
"displayName": "Test IOS Policy",
"description": "test",
"periodOfflineBeforeAccessCheck": "PT12H",
"periodOnlineBeforeAccessCheck": "PT30M",
"allowedInboundDataTransferSources": "allApps",
"allowedOutboundDataTransferDestinations": "allApps",
"organizationalCredentialsRequired": false,
"allowedOutboundClipboardSharingLevel": "allApps",
"dataBackupBlocked": true,
"deviceComplianceRequired": true,
"managedBrowserToOpenLinksRequired": false,
"saveAsBlocked": false,
"periodOfflineBeforeWipeIsEnforced": "P90D",
"pinRequired": true,
"maximumPinRetries": 5,
"simplePinBlocked": false,
"minimumPinLength": 4,
"pinCharacterSet": "any",
"allowedDataStorageLocations": [
"oneDriveForBusiness",
"sharePoint"
],
"contactSyncBlocked": false,
"printBlocked": false,
"fingerprintBlocked": false,
"targetedSecurityGroupIds": [ "valid directory group id 1",
"valid directory group id 2" ],
"appDataEncryptionType": "whenDeviceLocked"
}
响应:401 未经授权
{
"error": {
"code": "UnknownError",
"message": "{\"ErrorCode\":\"Forbidden\",\"Message\":\"An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: f932cecd-028f-42ea-9464-abf6e04f9ede - Url: https://fef.amsua0502.manage.microsoft.com/MAMAdmin/MAMAdminFEService/managedAppPolicies?api-version=2016-06-16 - CustomApiErrorPhrase: \",\"Target\":null,\"Details\":null,\"InnerError\":null,\"InstanceAnnotations\":[]}",
"innerError": {
"request-id": "f932cecd-028f-42ea-9464-abf6e04f9ede",
"date": "2017-03-03T17:44:10"
}
} }
我在 azure 门户上创建了一个 WebApp,并且还授予了我的应用程序的 DeviceManagementApps.ReadWrite.All 权限。access_token 是通过使用以编程方式获取的
https://login.microsoftonline.com/<tenantid>/oauth2/token
可以在应用程序的上下文中获取它,而不是在 Web 表单上提供用户凭据(用户授予方法)
PS 我已经确保从 clientid 和 secret 生成的 access_token 是正确的,因为相同的令牌在用于搜索 azure 上的组时有效。
GET https://graph.microsoft.com/beta/groups?$filter=startswith(displayName,%27test users%27)