Authenticate Users with OAuth

User authentication is a key component to many web applications. It allows the client application to identify the current user, and to potentially change their experience based on that information. Additionally, an authenticated user can also be authorized to perform specific actions depending on their account's permissions.

There are many different authentication and authorization patterns. OAuth is a common one, and the one we'll focus on in this tutorial. In the way we use it OAuth is similar to JSON Web Tokens (JWT), another approach commonly used with React applications. Drupal can be configured to act as the provider for both.

In this tutorial we'll:

  • Define a high-level strategy for handling authentication in our application that isn't specific to any authentication mechanism
  • Integrate some existing React components that manage OAuth authentication via Drupal into our application
  • Verify it's working by showing/hiding a component depending on the current user's authentication state

By the end of this tutorial you'll have a better understanding of how to integrate authentication into a Gatsby application, and specifically how to authenticate users against a Drupal OAuth provider.

Sign in with your Osio Labs account
to gain instant access to our entire library.