-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
37 lines (27 loc) · 1.23 KB
/
Program.cs
File metadata and controls
37 lines (27 loc) · 1.23 KB
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
using Auth0Net.DependencyInjection;
using Sample.ConsoleApp;
using Sample.ConsoleApp.Services;
using User;
var builder = Host.CreateApplicationBuilder(args);
builder.Logging.SetMinimumLevel(LogLevel.Debug);
// Configure the authentication client and token cache, as we'll need it
builder.Services.AddAuth0AuthenticationClient(config =>
{
config.Domain = builder.Configuration["Auth0:Domain"]!;
config.ClientId = builder.Configuration["Auth0:ClientId"];
config.ClientSecret = builder.Configuration["Auth0:ClientSecret"];
});
// Automatically add the authorization header with our token on every outgoing request
builder.Services
.AddHttpClient<UsersService>(x => x.BaseAddress = new Uri(builder.Configuration["AspNetCore:Url"]!))
.AddAccessToken(config => config.Audience = builder.Configuration["AspNetCore:Audience"]);
// Works for the Grpc integration too!
builder.Services
.AddGrpcClient<UserService.UserServiceClient>(x => x.Address = new Uri(builder.Configuration["AspNetCore:Url"]!))
.AddAccessToken(config =>
{
config.Audience = builder.Configuration["AspNetCore:Audience"];
});
builder.Services.AddHostedService<PumpingBackgroundService>();
var host = builder.Build();
await host.RunAsync();