Skip to content

Commit b469c65

Browse files
committed
Use MS Graph service from MIW
1 parent abbb861 commit b469c65

File tree

5 files changed

+8
-77
lines changed

5 files changed

+8
-77
lines changed

5-WebApp-AuthZ/5-2-Groups/MicrosoftGraphServiceExtensions.cs

Lines changed: 0 additions & 41 deletions
This file was deleted.

5-WebApp-AuthZ/5-2-Groups/Startup.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using Microsoft.Identity.Web.TokenCacheProviders.InMemory;
1212
using Microsoft.Identity.Web.UI;
1313
using WebApp_OpenIDConnect_DotNet.Services.GroupProcessing;
14-
using WebAppCallsMicrosoftGraph;
1514

1615
namespace WebApp_OpenIDConnect_DotNet
1716
{
@@ -49,12 +48,10 @@ public void ConfigureServices(IServiceCollection services)
4948
await GraphHelper.ProcessGroupsClaimforAccessToken(context);
5049
};
5150
}, options => { Configuration.Bind("AzureAd", options); })
52-
.EnableTokenAcquisitionToCallDownstreamApi(options=>Configuration.Bind("AzureAd", options))
51+
.EnableTokenAcquisitionToCallDownstreamApi(options => Configuration.Bind("AzureAd", options))
52+
.AddMicrosoftGraph(Configuration.GetSection("GraphAPI"))
5353
.AddInMemoryTokenCaches();
5454

55-
//Adds Microsoft Graph Client
56-
services.AddMicrosoftGraph(Configuration, new string[] { "User.Read", "GroupMember.Read.All" });
57-
5855
services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options => {
5956
// The following code instructs the ASP.NET Core middleware to use the data in the "groups" claim in the [Authorize] attribute and for User.IsInRole()
6057
// See https://docs.microsoft.com/en-us/aspnet/core/security/authorization/roles for more info.

5-WebApp-AuthZ/5-2-Groups/TokenAcquisitionCredentialProvider.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

5-WebApp-AuthZ/5-2-Groups/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.Identity.Web" Version="0.3.0-preview" />
22-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="0.3.0-preview" />
21+
<PackageReference Include="Microsoft.Identity.Web" Version="0.3.1-preview" />
22+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="0.3.1-preview" />
2323
</ItemGroup>
2424

2525
</Project>

5-WebApp-AuthZ/5-2-Groups/appsettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
// To call an API
1111
"ClientSecret": "[Copy the client secret added to the app from the Azure portal]"
1212
},
13+
"GraphAPI": {
14+
"BaseUrl": "https://graph.microsoft.com/v1.0",
15+
"Scopes": "User.Read GroupMember.Read.All"
16+
},
1317
"Logging": {
1418
"LogLevel": {
1519
"Default": "Information",

0 commit comments

Comments
 (0)