feat: support the OAuth client credentials grant - #340
Open
christiansmithdeveloper wants to merge 1 commit into
Open
feat: support the OAuth client credentials grant#340christiansmithdeveloper wants to merge 1 commit into
christiansmithdeveloper wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #339
Why
Zendesk is retiring API token (basic auth) authentication, and recommends the client credentials grant for server-to-server integrations where no user is present to authorise access.
The client already accepts an OAuth token (
ZendeskOptions.OAuthToken→Bearerheader) but has no way to obtain or renew one. That's a blocker for client credentials specifically, because:OAuthTokenis assigned once at registration, so a configured token inevitably goes stale.What
Adds first-class support for the client credentials grant:
ClientId/ClientSecret/Scope/ token-lifetime options onZendeskOptionsZendeskTokenProvider— obtains tokens fromPOST /oauth/tokens, caches them, and renews shortly before expiry (thread-safe, single-flight)ZendeskOAuthDelegatingHandler— sets a current token per request on the existingzendeskApiClientnamed client, so a renewed token is picked up without recreating the clientAddZendeskClientWithClientCredentials(...)registration overloadExisting basic-auth and static OAuth-token behaviour is unchanged. Version bumped
7.0.7→7.1.0, and the README documents the new option.Testing
Note for reviewers
Zendesk's docs describe this grant as requiring
grant_typeandclient_secretonly, but the endpoint rejects the request withinvalid_request: 'client_id' required.unlessclient_idis also sent. This is handled, and confirmed against a live instance.🤖 Implementation assisted by AI; written, reviewed, and tested by a human before submission.