This project is not covered by Drupal’s security advisory policy.

Define Simple OAuth consumers in code. Your site provides a known consumer in every environment, with no content entity to create or stage.

Features

Simple OAuth stores each consumer as a content entity. Content doesn't deploy with configuration, so each environment needs its own consumer: created by hand, by a script, or by a content migration. If the site depends on a known client ID, every environment has to get that consumer right.

This module defines the consumer in a YAML file in your codebase instead. The consumer deploys with the code, and it has the same client ID and settings in every environment. Add a MODULE.consumers.yml file to a custom module:

my_site.app:
  label: 'Site app'
  client_id: site_app
  redirect:
    - 'https://app.example.com/callback'

Only label and client_id are required. Every consumer plugin:

  • Is public. It has no secret and can't use the client credentials grant.
  • Requires PKCE by default.
  • Uses the authorization_code and refresh_token grants by default.
  • Never saves a consumer entity. Simple OAuth reads the consumer from the plugin, and tokens store its client ID.

You can also set description, grant_types, authorization_code_scopes, pkce, automatic_authorization, remember_approval, access_token_expiration, refresh_token_expiration, and third_party. They match the consumer fields of the same name.

Post-Installation

This module has no configuration page. Install it along with a module that provides a MODULE.consumers.yml file, and its consumers are ready to use. Rebuild caches after you edit a YAML file.

Consumer plugins don't appear on the Consumers list, because they're never saved.

If a saved consumer already uses the same client ID, the saved consumer wins. This holds even when it's disabled, so a plugin can't bring back a consumer that a site builder turned off.

Uninstalling the module that defines a consumer plugin deletes that consumer's tokens.

Additional Requirements

Similar projects

Simple OAuth's own consumer UI saves consumers as content on each site. Use it for consumers that differ between sites or environments, or that need a secret.

Supporting organizations: 
Development and maintainence

Project information

Releases