Skip to content

Client credentials grant#74

Open
abhishek-kaushik wants to merge 4 commits intoWP-API:mainfrom
abhishek-kaushik:client-credentials-grant
Open

Client credentials grant#74
abhishek-kaushik wants to merge 4 commits intoWP-API:mainfrom
abhishek-kaushik:client-credentials-grant

Conversation

@abhishek-kaushik
Copy link
Copy Markdown

@abhishek-kaushik abhishek-kaushik commented Mar 6, 2026

Adds support for the OAuth 2.0 Client Credentials grant type, enabling machine-to-machine authentication without user interaction. A client exchanges a client_id + client_secret for an access token that is not tied to any WordPress user.

@abhishek-kaushik abhishek-kaushik marked this pull request as ready for review March 31, 2026 10:04
const META_PREFIX = '_oauth2_access_';
const CLIENT_META_PREFIX = '_oauth2_client_token_';
const KEY_LENGTH = 12;
const DEFAULT_TTL = 86400; // 24 hours in seconds
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be backwards compatible -- i.e. tokens need to have no expiry by default. Perhaps there could be a way to set the default per oauth2 application though. Also, I think the expires should be part of a seperate PR, as i dont think it's hard-linked to the client credentials grant

/**
* Register settings, sections, and fields.
*/
function register_settings() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something here, but couldn't the client_credentials_enabled be a per oauth2 application setting? So any existing oauth2 app could have client credentials enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants