Why is 401 always returned in JwtBearerEvent OnChallenge?
emilwkarlsson opened this issue · 3 comments
When adding authentication in AddIdentityInfrastructure() in ServiceExtensions.cs, the code clearly states it should return 401 when OnChallenge event is invoked. Why is that? Nothing bad has really happened?
OnChallenge = context =>
{
context.HandleResponse();
context.Response.StatusCode = 401;
context.Response.ContentType = "application/json";
var result = JsonConvert.SerializeObject(new Response<string>("You are not Authorized"));
return context.Response.WriteAsync(result);
}
@emilwkarlsson Make sure you are passing auth token with prefix like "Bearer {YOUR TOKEN HERE}". and it will resolve your issue
@emilwkarlsson"Taşıyıcı {KENDİNİZ BURADAKİ TOKEN}" gibi bir ön ek ile yetkilendirme belirtecini ilettiğinizden emin olun. ve sorununuzu çözecektir
hi, i sent expired token to api.
statuscode cannot be set because the response has already started.
what are you know this problem ?
thanks
@emilwkarlsson Make sure you are passing auth token with prefix like "Bearer {YOUR TOKEN HERE}". and it will resolve your issue
Maaaan, so many thanks to you!