Skip to content

Add per-client token TTL and expiry support for client credentials#77

Open
abhishek-kaushik wants to merge 3 commits into
WP-API:mainfrom
abhishek-kaushik:token-expiry
Open

Add per-client token TTL and expiry support for client credentials#77
abhishek-kaushik wants to merge 3 commits into
WP-API:mainfrom
abhishek-kaushik:token-expiry

Conversation

@abhishek-kaushik
Copy link
Copy Markdown
Collaborator

@abhishek-kaushik abhishek-kaushik commented May 12, 2026

Summary

  • Per-client TTL setting — Each OAuth client can configure a token TTL (in seconds) via the admin UI. Existing clients default to no TTL (tokens never expire), preserving backwards compatibility.
  • Expiry stored on the tokenAccess_Token::create_for_client() reads the TTL from the client and sets an expires timestamp on the token at creation time.
  • Expired token rejection — The authentication layer rejects expired tokens with a 401 Unauthorized.
  • expires_in in token response — The /oauth2/access_token endpoint includes expires_in in the response only when the token actually has an expiry.

Backwards Compatibility

Existing clients have no TTL stored — tokens issued to them will not expire. New clients opt in by setting a TTL value in the admin UI.

@abhishek-kaushik abhishek-kaushik marked this pull request as ready for review May 12, 2026 09:41
@abhishek-kaushik abhishek-kaushik changed the title Token expiry Add per-client token TTL and expiry support for client credentials May 12, 2026
@joehoyle
Copy link
Copy Markdown
Member

@abhishek-kaushik could you give me a review of #75 (I added you to this repo) so we can merge tests, and then add test with this PR

@abhishek-kaushik
Copy link
Copy Markdown
Collaborator Author

@abhishek-kaushik could you give me a review of #75 (I added you to this repo) so we can merge tests, and then add test with this PR

sure @joehoyle , can do it

@joehoyle
Copy link
Copy Markdown
Member

Ok tests per merged, you should be able to add tests here now

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