Questions tagged [http-status-code-401]

Similar to 403 Forbidden, but specifically for use when authentication is possible but has failed or not yet been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource.

The request has not been applied because it lacks valid authentication credentials for the target resource.

The server generating a 401 response MUST send a WWW-Authenticate header field1 containing at least one challenge applicable to the target resource.

If the request included authentication credentials, then the 401 response indicates that authorization has been refused for those credentials. The user agent MAY repeat the request with a new or replaced Authorization header field2. If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user agent SHOULD present the enclosed representation to the user, since it usually contains relevant diagnostic information.

See

911 questions
3085
votes
17 answers

403 Forbidden vs 401 Unauthorized HTTP responses

For a web page that exists, but for which a user does not have sufficient privileges (they are not logged in or do not belong to the proper user group), what is the proper HTTP response to serve? 401 Unauthorized? 403 Forbidden? Something else? What…
80
votes
15 answers

401 Unauthorized: Access is denied due to invalid credentials

I am using IIS Express to deploy MVC4 application. This website runs perfectly on same computer. But in Lan it gives me error 401.
76
votes
8 answers

How do I get the HTTP status code with jQuery?

I want to check if a page returns the status code 401. Is this possible? Here is my try, but it only returns 0. $.ajax({ url: "http://my-ip/test/test.php", data: {}, complete: function(xhr, statusText){ alert(xhr.status); …
horgen
  • 2,093
  • 9
  • 29
  • 34
71
votes
9 answers

Unable to get windows authentication to work through local IIS

So I've created a new ASP.NET MVC project using the intranet template. web.config contains the appropriate values (e.g. ). If I fire up the web app using the VS webserver, it all looks fine - the page shows my Windows…
David
  • 14,678
  • 20
  • 80
  • 145
59
votes
2 answers

View Vimeo private video with an OAuth token

Can anyone give a help in Vimeo API using scribe? My goal is to access a private video (which I uploaded) without having to force the user to put password (this process should be done in background). From what I understand / deduce from research is…
JMarques
  • 2,812
  • 4
  • 27
  • 49
53
votes
4 answers

How to handle 401 (Authentication Error) in axios and react?

I have one file request.js which contains wrapper for axios ajax request. I am calling request function from multiple react components and when one of the request fails I want to refresh the token and retry all the failed requests again. I can use…
Amir Saleem
  • 1,576
  • 1
  • 14
  • 26
45
votes
7 answers

Is it possible to send a 401 Unauthorized AND redirect (with a Location)?

I'd like to send a 401 Unauthorized AND redirect the client somewhere. However: if I do it like this: header('HTTP/1.1 401 Unauthorized'); header('Location: /'); the server sends a 302 Found with Location, so not a 401 Unauthorized. If I do it like…
Rudie
  • 46,504
  • 37
  • 126
  • 167
40
votes
2 answers

Authorization in RESTful HTTP API, 401 WWW-Authenticate

I'm creating a RESTful service to provide data to a web application. I have two related questions about this. 1. How to deal with unauthorized requests? I'm intending to respond to requests with the following codes: Is the resource open and found?…
Aidiakapi
  • 5,590
  • 3
  • 30
  • 58
37
votes
13 answers

GCM http 401 authorization error

When my backend server sends post requests to GCM servers I get an authorization error HTTP 401. I followed the steps described here: http://developer.android.com/google/gcm/http.html#auth_error >> api_key=AIzaSyDEy3... >> curl --header…
35
votes
3 answers

401 Unauthorized vs 403 Forbidden: Which is the right status code for when the user has not logged in?

After lots of Googling and Stackoverflowing, it still isn't clear to me because many articles and questions/answers were too general (including 403 Forbidden vs 401 Unauthorized HTTP responses which was not specifically for my use-case). Question:…
32
votes
5 answers

HTTP Error 401.2 - Unauthorized You are not authorized to view this page due to invalid authentication headers

i want to allow access to Anonymous.aspx page to all user, i have set Basic Authentication to Enabled, and Connect as to specific user. my problem is when trying to access http://MyIPAddress/MyAlias/Anonymous.aspx, authentication popup…
31
votes
5 answers

Spring RestTemplate invoking webservice with errors and analyze status code

I designed a webservice to perform a task if request parameters are OK, or return 401 Unauthorized HTTP status code if request parameters are wrong or empty. I'm using RestTemplate to perform a test and I'm able to verify the HTTP 200 OK status if…
Premier
  • 3,952
  • 6
  • 39
  • 56
29
votes
1 answer

Intermittent 401 Unauthorized from Google GCM

We are getting intermittent 401 Unauthorized errors from Google's GCM service. In the past it worked 100% of the time. The problem might coincide with our routers accepting IPv6 traffic, but the problem remains now even if we disable IPv6 on the…
28
votes
1 answer

Angular.js $http.post TypeError: Cannot read property 'data' of undefined

Angular.js v1.0.6 When making an $http.post and receiving a non 200 resposne (401 in this case) $http.post('http://localhost:3030/auth/login', { username: 'username', password: 'password' }) .success(function(data) { // Gets called on a 200…
28
votes
7 answers

Avoiding 401 response for each request using NTLM

We have here an asp.net 3.5 application using NTLM based windows authentication. The system runs on a private network that actually distributed over different geographic places (connected via VPN). We are now trying to optimize the website's…
Satumba
  • 830
  • 1
  • 9
  • 20
1
2 3
60 61