0
rebit created
Hi.
I'm trying to expose an application service method to a 3rd party that determines whether the user should be authorised to access the method inside of the method. If authorisation is required, I want to return a 401 HTTP code.
What I've done is to throw a AbpAuthorizationException when authorisation is required, but this redirects the request to the application login page with a 302 response code. I want to return a 401 response to allow the 3rd party to authenticate the user.
How can I accomplish this?
9 Answer(s)
-
0
I have finally managed to solve the issue.
It looks like I did not upgrade the WebAPI project correctly.
The line below was missing from my WebApi Module's Initialize() method:
Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer"));
Once added, the 401 response code is returned.
Have an answer to this question?
Log in
and write your answer.