Setup API Key Authentication in Drupal
API Key Authentication offers a simple and effective way to secure Drupal APIs. After generating API keys for users, these keys act as unique identifiers that help manage and safeguard access to your Drupal APIs. For authentication, the client must send the user’s Drupal username along with their API key in the Authorization header of each request. The Drupal API Authentication module verifies this combination before granting access. The module supports Drupal 8, 9, 10, and 11.
- Using Composer
- Using Drush
- Manual Installation
Pre-requisites:
- REST UI: This module provides a user-friendly interface to configure the REST module.
- Enable the following Web Services modules from the Extend section (/admin/modules) of your Drupal site:
- JSON:API
- REST UI
- RESTful Web Services
- Serialization
Enable API and Assign Methods:
- The first step is to enable the API and assign the methods and operations allowed for that API. This can be done using the REST UI module, or by directly modifying the Drupal config.
- Click on the Enable API button.
- To enable the API using the REST UI module, click the Configure button (as shown below).
- In our example, we need to enable the /entity/user API. To do this, click the Enable option in front of it.
- Since our goal is to create a user in Drupal, select the following configurations:
- Method: POST
- Format: JSON
- Authentication Provider: rest_api_authentication
- This allows the miniOrange API Authentication module to authenticate the API. Click the Save Configuration button to continue.
Configuration Steps
Setup API Key Authentication Method:
- In this step, we will generate an API Key. To do this, navigate to the API Authentication tab of the module (/admin/config/people/rest_api_authentication/auth_settings).
- Under Basic Configuration, enable the Enable Authentication toggle.
- Enter the Application Name and select API Key from the Authentication Method section.
- Basic Authentication
- API Key Authentication
Congratulations! You have successfully set up the API Key Authentication method using the Drupal API Authentication module.
If the configuration was not successful, please contact us at drupalsupport@xecurify.com. Kindly include a screenshot of the error window, and we will assist you in resolving the issue and guide you through the setup.
Thank you for your response. We will get back to you soon.
Something went wrong. Please submit your query again
