Module Development

Get a Token for OAuth 2 Requests for Drupal 8, 9, 10, and 11

In order to authenticate a request against the API server, we need to send an authentication token along with the request. For that we need to first obtain the token from the server. The various ways we can get a token from the server are called grants. Using one of them, we will obtain an access token and a refresh token.

In this tutorial we will:

  • Learn how OAuth 2 grants work
  • Learn how to generate and request authentication tokens
  • Learn how to generate and request refresh tokens

By the end of this tutorial you should be able to exchange a user name and password for OAuth 2 authentication and refresh tokens so that your API client can make authenticated requests.

Decoupled Headless Drupal