HTTP 401 Unauthorized Error - Meaning & Fix

The HTTP 401 Unauthorized status code means your request was not completed because it lacks the necessary authentication credentials. This code is accompanied by a WWW-Authenticate header providing details on how to authenticate. Unlike the 403 Forbidden status, authentication may grant access to the resource.

Main causes

  • Incorrect or missing credentials provided by the client.

  • The authentication method required by the server is not supported by the client.

  • The authentication data provided by the client has expired or is no longer valid.

  • The client did not provide any authentication data.

# Request example 
curl -X PUT https://sandbox.oxylabs.io/ -H 'Accept: application/xml;q=0.9' -H 'Accept-Encoding: compress' -H 'User-Agent: Mozilla/5.0'

Try Scraper API with 5K results

Common fixes

  • Ensure that the correct authentication credentials (username and password) are used for the request.

  • Check if the authentication method (e.g., Basic, OAuth, Bearer Token) required by the API or resource is correctly implemented in the request header.

  • Verify that the account associated with the credentials has sufficient permissions to access the requested resource.

  • Confirm that the authentication credentials have not expired or been revoked, and renew or update them if necessary.

# Response example 
HTTP/1.1 401 Unauthorized
Content-Type: text/xml
WWW-Authenticate: Basic realm="Access to the staging site"



401
Unauthorized: Access is denied due to invalid credentials.

Forget HTTP errors with Scraper API

Web scraper API

Self-Service

Public data delivery from a majority of websites

From

49

Useful resources

Get the latest news from data gathering world

I'm interested