-
Notifications
You must be signed in to change notification settings - Fork 219
/
Copy pathAllApps.cshtml.cs
37 lines (32 loc) · 1.09 KB
/
AllApps.cshtml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using Microsoft.Graph;
using Microsoft.Identity.Web;
namespace WebAppCallsMicrosoftGraph.Pages
{
/// <summary>
/// Tests the app-only permissions - need to have been granted by the tenant admin first.
/// </summary>
public class AllAppsModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private readonly GraphServiceClient _graphServiceClient;
public AllAppsModel(ILogger<IndexModel> logger, GraphServiceClient graphServiceClient)
{
_logger = logger;
_graphServiceClient = graphServiceClient;
}
public int NumberOfApps { get; private set; }
public async Task OnGet()
{
var messages = await _graphServiceClient.Applications
.Request()
.WithAppOnly()
.GetAsync();
NumberOfApps = messages.Count;
}
}
}