-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
43 lines (34 loc) · 1.54 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using CallScheduler;
using CallScheduler.Graph;
using MudBlazor.Services;
using MudBlazor;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
// HttpClient for passing into GraphServiceClient constructor
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://graph.microsoft.com") });
builder.Services.AddMsalAuthentication<RemoteAuthenticationState, RemoteUserAccount>(options =>
{
var scopes = builder.Configuration.GetValue<string>("GraphScopes");
if (string.IsNullOrEmpty(scopes))
{
Console.WriteLine("WARNING: No permission scopes were found in the GraphScopes app setting. Using default User.Read.");
scopes = "User.Read";
}
foreach(var scope in scopes.Split(';'))
{
Console.WriteLine($"Adding {scope} to requested permissions");
options.ProviderOptions.DefaultAccessTokenScopes.Add(scope);
}
builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);
})
.AddAccountClaimsPrincipalFactory<RemoteAuthenticationState, RemoteUserAccount, GraphUserAccountFactory>();
builder.Services.AddScoped<GraphClientFactory>();
builder.Services.AddMudServices(config =>
{
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.TopRight;
});
await builder.Build().RunAsync();