Setup Basic Authentication - miniOrange

Last updated on
28 November 2025

Note: Drupal Core comes with a Basic Authentication module.

Basic Authentication is a very simple and straight-forward Authentication method. The client sends HTTP requests with an Authorization header that contains a base64-encoded  username and password of your Drupal site.

In Basic Authentication, the miniOrange API authentication module will first authenticate the user against their Drupal username and password. If the user is authenticated, only then the user will be able to perform that operation. This module is compatible with Drupal 8, Drupal 9, Drupal 10, and Drupal 11.

Disclaimer: This document only covers the miniOrange API Authentication Module. 

  Download    Know more

Setup Video:

 Drupal REST API BAsic Authentication Youtube Video

Pre-requisites: Download and Installation:

  • Download & install the Drupal REST & JSON API Authentication module.
  • REST UI: This module provides you with a user interface for configuring the REST module. 
  • Enable the following Web Services modules from under the Extend section (/admin/modules) of your Drupal site:
    • JSON: API
    • REST UI
    • RESTful Web Services
    • Serialization

Drupal API Authentication install Web Services

Enable the API, assign methods and operations as follows:

  • The first step is to enable the API and also assign methods and operations allowed on that particular API. This can be done using the REST UI module, or you can simply modify the config.
  • To enable the API using the REST UI module, click on the Configure button of the REST UI module.

Drupal API Authentication configure REST UI module

  • Considering our example, we want to enable the /node/{node} API present under the Content section. Enable this API using the Enable option in front of it.

Drupal API Authentication enable content services

  • Now, as our goal is to retrieve the node information, select the following configs:
    • Method: GET
    • Format: json
    • Authentication provider: rest_api_authentication.
  • This will allow the miniOrange REST API Authentication module to authenticate your API. Click on the Save Configuration button to continue.

Drupal API Authentication settings for resource content

Setup Basic Authentication Method:

  • In this step, we will set up Basic Authentication as an API Authentication method. To do so, please navigate to the API Authentication tab of the REST API Authentication Module. (/admin/config/people/rest_api_authentication/auth_settings)
    • Under Basic Configuration, enable the Enable Authentication checkbox.​​​​
    • Enter the Application Name and click on the Save Configuration button.
    • Scroll down to the Authentication Method section on the same tab and select the Basic Authentication method.

Drupal API Authentication enable basic Authentication

  • You have successfully configured the Basic Authentication method.

Note: Use the application-specific unique header when authenticating the API.

Drupal API Authentication method configured successfully

That’s it!!!
Now let’s try to fetch node information through an API call using Basic authentication.

Example:

  • To get node information in Drupal, make a GET request with the user’s Drupal username and password. The username and password must be in Base64-encoded format. You can refer to the format below to make the call.
HTML Request Format-
    
Request: GET <your_drupal_base_url> /node/{node}?_format=json
Header: 

 AUTH-METHOD: application_id
 Accept: application/json
 Content-Type: application/json
 Authorization: Basic base64encoded<username:password>


CURL Request Format-
curl --location --request GET 'drupal_base_url/node/1?_format=json' \

--header 'AUTH-METHOD: application_id' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic base64encoded <username:password'>
  • You can also refer to the image of the Postman request added below:

Drupal API Authentication Basic Authentication postman request

  • A successful response returns the node information that you have created.

Drupal API Authentication Postman response

  • If you receive an error in the response, refer to the table below for the error description and possible solutions.
Error Description
MISSING_HEADER

You will get this error if you don’t send a Unique header in the API request, or if your server removes it for some reason.

Example:

{
"status": "error",
"http_code": 400,
"error": "MISSING_HEADER",
"error_description": "Missing required unique header. It should contain the application ID."
}

MISSING_AUTHORIZATION_HEADER

You will get this error if you don’t send an Authorization header in the API request, or if your server removes it for some reason.

Example:

{
"status": "error",
"http_code": "401",
"error": "MISSING_AUTHORIZATION_HEADER",
"error_description": "Authorization header not received."
}

INVALID_AUTHORIZATION_HEADER_TOKEN_TYPE You will get this error if the Authorization header is sent but not in a valid format.
Example:
{
"status": "error",
"http_code": "405",
"error": "INVALID_AUTHORIZATION_HEADER_TOKEN_TYPE",
"error_description": "Authorization header must be the type of Basic."
}
USER_NAME_MISSING

You will get this error whenever the module is not able to find the username in the API call.

Example:

{
"status": "error",
"http_code": "401",
"error": "MISSING_USERNAME",
"error_description": "The username is missing from the request."
}

INVALID_CREDENTIALS

You will get this error when either the username or password is incorrect.

Example:

{
"status": "error",
"http_code": "401",
"error": "INVALID_CREDENTIALS",
"error_description": "Invalid username or password."
}

Congratulations!!!! You can now authenticate any calls to your Drupal APIs using Basic Authentication.

We hope you found this document useful and informative.

Contact our 24*7 support team

Feel free to reach out to our Drupal experts if you need any sort of assistance in setting up REST & JSON API Authentication on your Drupal site.   

 Get In Touch With Us Join Our Slack Channel

back to top Back to top  

Help improve this page

Page status: No known problems

You can: