HansMusterWhatElse
HansMusterWhatElse

Reputation: 671

AngularJS - Authentication with Bearer Token and Web API 2.0

I have the problem that even though I set the $http.defaults.headers.common.Authorization to null I am still capable of accessing the [Authorize] part of my Web API 2.0 application.

This problem doesn't arise when I start the application from scratch and try to retrieve the data via an initial GET request. This is when I get an error from the $http callback function.

Any guesses why this is happening? I am quite confident that the bearer token is stored somewhere in the browser and doesn't get deleted properly ...

Chrome (With bearer token):

enter image description here

Chrome (Without bearer token):

enter image description here

Internet Explorer (no bearer Token attribute):

enter image description here

First of all, the authentication property in IE is completely missing. Second, in Chrome everything works perfectly. In IE I have the issue that I can't erase the token for the logout request. The login part with the summary of the regions [Authorize] part works perfectly.

Upvotes: 0

Views: 3828

Answers (2)

dco
dco

Reputation: 327

Try to check the request that have been set, if any Authentification header is there. Also try to verify that you are using the [Authorize] attribute from System.Web.Http and not System.Web.Mvc

Upvotes: 1

NevilleS
NevilleS

Reputation: 1209

Make sure you haven't also configured jQuery to do this, via something like $.ajaxSetup

Upvotes: 1

Related Questions