diff --git a/web-app-aspnet/Pages/Index.cshtml.cs b/web-app-aspnet/Pages/Index.cshtml.cs index 14033da..9d5200b 100644 --- a/web-app-aspnet/Pages/Index.cshtml.cs +++ b/web-app-aspnet/Pages/Index.cshtml.cs @@ -5,7 +5,7 @@ namespace sign_in_webapp.Pages; -[AuthorizeForScopes(ScopeKeySection = "DownstreamApi:Scopes")] +[AuthorizeForScopes(ScopeKeySection = "DownstreamApis:MicrosoftGraph:Scopes")] public class IndexModel : PageModel { private readonly ILogger _logger; @@ -21,7 +21,7 @@ public IndexModel(ILogger logger, public async Task OnGet() { - using var response = await _downstreamWebApi.CallApiForUserAsync("DownstreamApi").ConfigureAwait(false); + using var response = await _downstreamWebApi.CallApiForUserAsync("MicrosoftGraph").ConfigureAwait(false); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var apiResult = await response.Content.ReadFromJsonAsync().ConfigureAwait(false); diff --git a/web-app-aspnet/Program.cs b/web-app-aspnet/Program.cs index 45b352d..714c892 100644 --- a/web-app-aspnet/Program.cs +++ b/web-app-aspnet/Program.cs @@ -7,12 +7,13 @@ // WebApplicationBuilder builder = WebApplication.CreateBuilder(args); -IEnumerable? initialScopes = builder.Configuration.GetSection("DownstreamApi:Scopes").Get>(); +IEnumerable? initialScopes = builder.Configuration.GetSection("DownstreamApis:MicrosoftGraph:Scopes").Get>(); builder.Services.AddMicrosoftIdentityWebAppAuthentication(builder.Configuration, "AzureAd") .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) - .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); +builder.Services.AddDownstreamApis(builder.Configuration.GetSection("DownstreamApis")); + // // diff --git a/web-app-aspnet/WebApp.csproj b/web-app-aspnet/WebApp.csproj index 9342564..f02f53e 100644 --- a/web-app-aspnet/WebApp.csproj +++ b/web-app-aspnet/WebApp.csproj @@ -6,8 +6,8 @@ sign_in_webapp - - - + + + \ No newline at end of file diff --git a/web-app-aspnet/appsettings.json b/web-app-aspnet/appsettings.json index a9a6fd5..12f26ac 100644 --- a/web-app-aspnet/appsettings.json +++ b/web-app-aspnet/appsettings.json @@ -3,7 +3,7 @@ "Instance": "https://login.microsoftonline.com/", "TenantId": "Enter the tenant ID obtained from the Microsoft Entra admin center", "ClientId": "Enter the client ID obtained from the Microsoft Entra admin center", - "ClientCertificates": [ + "ClientCredentials": [ { "SourceType": "StoreWithThumbprint", "CertificateStorePath": "CurrentUser/My", @@ -12,12 +12,14 @@ ], "CallbackPath": "/signin-oidc" }, - "DownstreamApi": { - "BaseUrl": "https://graph.microsoft.com/v1.0/", - "RelativePath": "me", - "Scopes": [ - "user.read" - ] + "DownstreamApis": { + "MicrosoftGraph" :{ + "BaseUrl": "https://graph.microsoft.com/v1.0/", + "RelativePath": "me", + "Scopes": [ + "user.read" + ] + } }, "Logging": { "LogLevel": {