forked from Azure-Samples/ms-identity-docs-code-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
29 lines (24 loc) · 1.09 KB
/
Program.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
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using BlazorWasm;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddMsalAuthentication(options =>
{
builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);
options.ProviderOptions.DefaultAccessTokenScopes
.Add("https://graph.microsoft.com/User.Read");
});
builder.Services.AddScoped(sp =>
{
var authorizationMessageHandler =
sp.GetRequiredService<AuthorizationMessageHandler>();
authorizationMessageHandler.InnerHandler = new HttpClientHandler();
authorizationMessageHandler.ConfigureHandler(
authorizedUrls: new[] { "https://graph.microsoft.com/v1.0" },
scopes: new[] { "User.Read" });
return new HttpClient(authorizationMessageHandler);
});
await builder.Build().RunAsync(CoreDispatcherPriority.Normal);