I am passing token from my UI repo to backend.
export class AccountService {
constructor(private http: HttpClient, private oidcSecurityService: OidcSecurityService) {}
.
.
.
const options = {
headers: new HttpHeaders({
Authorization: 'Bearer ' + token,
'Content-Type': 'application/json',
}),
};
debugger;
return this.http.get<IRetrieveAccountSummaryResponse>(
AppConfig.settings.businessUrl + '/api/account/AccountSummary/' + loanNumber,
options
);
In API package, I have added below code in Startup.cs
services.AddAuthentication("Bearer")
.AddJwtBearer("Bearer", options =>
{
options.Authority = Configuration[AuthServiceEndpoint];
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
ValidateIssuer = false,
ValidateAudience = false
};
});
services
.AddAuthorization(options =>
{
options.DefaultPolicy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.AddAuthenticationSchemes("Bearer")
.Build();
});
app.UseAuthentication();
app.UseAuthorization();
When I try to load page, it gives 401 error. When I checked Network tab, it says
www-authenticate: Bearer error="invalid_token", error_description="The signature key was not found"
Under Request HEaders, I can see
authorization: Bearer eyJhbGciOiJSUzI1N.......
I am not sure what is incorrect in this case.
Bearer error - invalid_token - The signature key was not found It did not help me.