Поддерживается получение разрешений приложения через GET /applications/{id}
конечную точку , но только в версии /beta
на данный момент
API в / бета-версии в Microsoft Graph могут быть изменены.
Использование этих API в рабочих приложениях не поддерживается.
Детали
Конечная точка GET /applications/{id}/requiredResourceAccess
возвращает RequiredResourceAccess
коллекция , которая:
ресурсов, к которым этому приложению требуется доступ, и набор
Области разрешений OAuth и роли приложений, необходимые для каждого
из этих ресурсов
C # пример (через msgraph-sdk-dotnet
library )
var requestUrl = $"{graphClient.BaseUrl}/applications/{id}/requiredResourceAccess";
var message = new HttpRequestMessage(HttpMethod.Get, requestUrl);
await graphClient.AuthenticationProvider.AuthenticateRequestAsync(message);
var response = await graphClient.HttpProvider.SendAsync(message);
var content = await response.Content.ReadAsStringAsync();
var resourceAccesses = JsonConvert.DeserializeObject<List<RequiredResourceAccess>>(JObject.Parse(content)["value"].ToString());
, где
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class RequiredResourceAccess
{
/// <summary>
/// The unique identifier for the resource that the application requires access to.
/// This should be equal to the appId declared on the target resource application
/// </summary>
[JsonProperty("resourceAppId")]
public string ResourceAppId { get; set; }
/// <summary>
/// The list of OAuth2.0 permission scopes and app roles that the application requires from the specified resource.
/// </summary>
[JsonProperty("resourceAccess")]
public List<ResourceAccess> ResourceAccess { get; set; }
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class ResourceAccess
{
/// <summary>
/// The unique identifier for one of the oAuth2Permission or appRole instances that the resource application exposes.
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }
/// <summary>
/// Specifies whether the id property references an oAuth2Permission or an appRole. Possible values are "scope" or "role".
/// </summary>
[JsonProperty("type")]
public string Type { get; set; }
}
Поскольку указанная конечная точка возвращает результат в следующем формате:
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#applications('e7de2f36-a0c1-4573-91bd-c854eaff0852')/requiredResourceAccess",
"value": [
{
"resourceAppId": "00000003-0000-0000-c000-000000000000",
"resourceAccess": [
{
"id": "1ec239c2-d7c9-4623-a91a-a9775856bb36",
"type": "Scope"
},
//...
]
},
{
"resourceAppId": "00000003-0000-0ff1-ce00-000000000000",
"resourceAccess": [
{
"id": "d13f72ca-a275-4b96-b789-48ebcc4da984",
"type": "Role"
}
]
}
]
}
вам может потребоваться получить сведения о ресурсе, к которому приложению требуется доступ, и области разрешений (например, API и имя разрешения, которое отображается на странице разрешений API Azure Portal) *
В этом отношении GET /servicePrincipals
конечная точка может быть использована.
Пример: * * тысяча пятьдесят-три
Для ресурса с идентификатором 00000003-0000-0000-c000-000000000000
запрос https://graph.microsoft.com/beta/servicePrincipals?filter=appId eq '00000003-0000-0000-c000-000000000000'
возвращает следующий ответ:
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#servicePrincipals",
"value": [
{
"id": "414583a1-9d42-4309-aa10-3bf73ff7f95e",
"appDisplayName": "Microsoft Graph",
"appId": "00000003-0000-0000-c000-000000000000",
//...
"publishedPermissionScopes": [
{
"adminConsentDescription": "Allows the app to create, read, update, and delete events in user calendars. ",
"adminConsentDisplayName": "Have full access to user calendars ",
"id": "1ec239c2-d7c9-4623-a91a-a9775856bb36",
"isEnabled": true,
"type": "User",
"userConsentDescription": "Allows the app to read, update, create and delete events in your calendars. ",
"userConsentDisplayName": "Have full access to your calendars ",
"value": "Calendars.ReadWrite"
},
//...
]
}
]
}
, который содержит подробную информацию о ресурсе (например, appDisplayName:Microsoft Graph
) и объемах разрешений (например, value:Calendars.ReadWrite
)