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_codeandrefresh_tokengrants 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
- Drupal 11.1 or later
- Simple OAuth 6.1.5 or later
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.
Project information
- Project categories: Access control, Decoupled, Integrations
- Ecosystem: Simple OAuth (OAuth2) & OpenID Connect
- Created by mglaman on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
