Backend and Infrastructure

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

To authenticate a request against the API server, we must send an authentication token along with the request. For that, we need first to 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 use the OAuth 2 authorization code flow (using PKCE) to authenticate a user and obtain access and refresh tokens that your API client can use to make authenticated requests.

Decoupled Headless Drupal