Authenticate user token in the backend service¶
To validate that user token is valid in the backend service.
Setup variables:
- IssuerUrl points to the platform oauth server
- App Id is the registered application id of the client
var IssuerUrl = "https://login.mike-cloud.com"
var allowAudiences = new List<string> { "<App id>"};
for non production environments the issuer url is
var IssuerUrl = $"https://login.mike-cloud-{environment.ToString().ToLower()}.com";
Add authentication in the ConfigureServices initialization
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = IssuerUrl;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidAudiences = allowAudiences
};
});
For more coplex scenarios and swagger authenticaiton contact wdpservice.