Skip to content

Commit 01cfe05

Browse files
committed
update graph sample
1 parent 2b30a7d commit 01cfe05

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

2-WebApp-graph-user/2-1-Call-MSGraph/Controllers/HomeController.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.Extensions.Configuration;
77
using Microsoft.Extensions.Logging;
88
using Microsoft.Graph;
9+
using Microsoft.Graph.Models;
910
using Microsoft.Identity.Client;
1011
using Microsoft.Identity.Web;
1112
using System;
@@ -25,7 +26,7 @@ public class HomeController : Controller
2526

2627
private readonly MicrosoftIdentityConsentAndConditionalAccessHandler _consentHandler;
2728

28-
private string[] _graphScopes;
29+
private readonly string[] _graphScopes;
2930

3031
public HomeController(ILogger<HomeController> logger,
3132
IConfiguration configuration,
@@ -34,7 +35,7 @@ public HomeController(ILogger<HomeController> logger,
3435
{
3536
_logger = logger;
3637
_graphServiceClient = graphServiceClient;
37-
this._consentHandler = consentHandler;
38+
_consentHandler = consentHandler;
3839

3940
// Capture the Scopes for Graph that were used in the original request for an Access token (AT) for MS Graph as
4041
// they'd be needed again when requesting a fresh AT for Graph during claims challenge processing
@@ -54,7 +55,7 @@ public async Task<IActionResult> Profile()
5455

5556
try
5657
{
57-
currentUser = await _graphServiceClient.Me.Request().GetAsync();
58+
currentUser = await _graphServiceClient.Me.GetAsync();
5859
}
5960
// Catch CAE exception from Graph SDK
6061
catch (ServiceException svcex) when (svcex.Message.Contains("Continuous access evaluation resulted in claims challenge"))
@@ -75,7 +76,7 @@ public async Task<IActionResult> Profile()
7576
try
7677
{
7778
// Get user photo
78-
using (var photoStream = await _graphServiceClient.Me.Photo.Content.Request().GetAsync())
79+
using (var photoStream = await _graphServiceClient.Me.Photo.Content.GetAsync())
7980
{
8081
byte[] photoByte = ((MemoryStream)photoStream).ToArray();
8182
ViewData["Photo"] = Convert.ToBase64String(photoByte);

2-WebApp-graph-user/2-1-Call-MSGraph/Views/Home/Profile.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<th></th>
2929
</tr>
3030
@{
31-
var user = ViewData["me"] as Microsoft.Graph.User;
31+
var user = ViewData["me"] as Microsoft.Graph.Models.User;
3232
<tr>
3333
<th>
3434
ID

2-WebApp-graph-user/2-1-Call-MSGraph/WebApp-OpenIDConnect-DotNet-graph.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="2.12.1" />
12+
<PackageReference Include="Microsoft.Identity.Web.GraphServiceClientBeta" Version="2.12.1" />
1313
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.12.1" />
1414
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.5" />
1515
</ItemGroup>

0 commit comments

Comments
 (0)