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

1109 questions
15
votes
5 answers

The request failed with HTTP status 401: Unauthorized

I have a .NET 2.0 website (VB) running in my IIS6 (XP Pro SP2) and a .NET 3.5 (configured as .NET2 under IIS's ASP.NET tab, of course) hosting an ASMX web service. In Chrome, I can call the ASMX and invoke the web methods successfully. However, in…
Matt W
  • 11,753
  • 25
  • 118
  • 215
14
votes
5 answers

Using RoboSpice is there a way to get the HTTP Error Code out of an exception?

I am writing an application that uses RoboSpice. In the request listener onRequestFailure( SpiceException arg0 ) is there a way to know for sure that the error was a result of a 401 HTTP Error occurred? I have a back end service, that returns a 401…
JLamkin
  • 721
  • 6
  • 17
13
votes
2 answers

Handling Authentication in Okhttp

I'm using OkHttp 2.3 with basic authentication requests, according to OKHttp docs, it automatically retries unauthenticated requests, but whenever I provide invalid credentials, the request takes too much time and I get this exception in the…
Silvia H
  • 8,097
  • 7
  • 30
  • 33
13
votes
3 answers

'Login as another user' MVC 4 Windows Authentication

I have an intranet project written in MVC 4 which uses Windows Authentication to authorise and authenticate users. I need to add a 'Login as another user' functionality. After some searching I found this solution which suggests returning a 401, and…
Darbio
  • 11,286
  • 12
  • 60
  • 100
12
votes
3 answers

Access Exchange Web Services with PHP and cURL

Hello, I am currently writing a client to access a Microsoft Exchange server and read contacts, appointments etc. from it. Through days of searching I've been able to connect to the EWS via PHP's Soap client and a custom HTTPS Stream wrapper. This…
DarkDevine
  • 1,047
  • 1
  • 9
  • 12
12
votes
1 answer

Setting authorization header in axios

I have been trying to make a GET request to the National Park Service API with axios and have tried several ways to set my API key in the request header to no avail. Any assistance will be greatly appreciated. I have…
jcarapia
  • 578
  • 1
  • 7
  • 20
12
votes
3 answers

The remote server returned an error: (401) Unauthorized

I'm trying to get the html code of certain webpage, I have a username and a password that are correct but i still can't get it to work, this is my code: private void buttondownloadfile_Click(object sender, EventArgs e) { NetworkCredentials nc =…
Zaidman
  • 121
  • 1
  • 1
  • 3
12
votes
2 answers

Get rid of a 401 (unauthorized) ajax error in browser console

I'm calling an api through javascript using a jQuery.ajax call. The api respond with 401 if the user is not authenticated and I want to ignore this error only for this call. I've tried all the callback options described in the jQuery options but the…
Fabio
  • 18,856
  • 9
  • 82
  • 114
11
votes
2 answers

Android: HttpsUrlConnection with Authenticator for Basic Authentication iterates forever when password is wrong (on 401 response)

I am using an HttpsUrlConnection with Basic Authentication by using an Authenticator and setting a default Authenticator object like this: Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication…
Jens
  • 6,243
  • 1
  • 49
  • 79
11
votes
3 answers

Service-Worker, "TypeError:Request failed at "

I hope you can help me with my problem. Currently I build a PWA with a service-worker. It registerd successful, but something is wrong with the installation. The "caches.open"-promise result in an error: "TypeError: Request failed at ". You can see…
11
votes
1 answer

Catch 401 Exception in Angular2

When i try to connect to an unauthorized URL i get in Chrome: zone.js:1274 POST http://localhost:8080/rest/v1/runs 401 (Unauthorized) core.umd.js:3462 EXCEPTION: Response with status: 401 Unauthorized for URL: http://localhost:8080/rest/v1/runs The…
ManfredP
  • 1,037
  • 1
  • 12
  • 27
10
votes
4 answers

strange 401 error appears for some urls when using .htaccess to redirect http to https

OK, here is the 7th day of unsuccessfull attempt to find an answer why 401 error appears... Now, .htaccess in the root folder contains the only 3 strings (was simplified) and there are NO more .htaccess files in the project: RewriteEngine…
Haradzieniec
  • 9,086
  • 31
  • 117
  • 212
10
votes
2 answers

WCF REST Service - 401 Unauthorized

We're in the process of developing a WCF REST web service which just receives a bunch of arbitrary text from any anonymous user and then performs some processing on the back end. For example, here's one method from our web…
Jacobs Data Solutions
  • 4,850
  • 4
  • 33
  • 38
10
votes
5 answers

Why does toaster service inside Global Error Handler wont work in Angular4/5/6?

My requirement is to load some data by calling Two Rest Api's before app component loads.If API gives any error display the message in Toaster (angular2-toaster). Before loading app component the below AppLoadService executes import { Injectable }…
10
votes
1 answer

Chrome: Basic Auth image requests return 401, but not when called directly

Chrome throws 401 restricted errors for Basic auth'd IMG-urls in the vein of http://user:pass@path.to/image, but did not do this before with the same resources and code. When called directly, as in "open in new tab" the images load without a hitch.…
reinhardt
  • 351
  • 5
  • 14
1 2
3
73 74