Setup Basic Authentication - miniOrange
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.
Setup 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

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.

- 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.

- 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.

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.

- You have successfully configured the Basic Authentication method.
Note: Use the application-specific unique header when authenticating the API.

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:

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

- 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: { |
| 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: { |
| 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: { |
| INVALID_CREDENTIALS |
You will get this error when either the username or password is incorrect. Example: { |
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.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion
Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.