Repository navigation
feat: add client credentials token support for M2M - #138
Merged
Merged
Conversation
kishore7snehil
marked this pull request as ready for review
October 6, 2026 06:50
nandan-bhat
reviewed
Oct 7, 2026
kishore7snehil
force-pushed
the
feat/m2m-client-credentials
branch
from
October 8, 2026 04:07
fcb1832 to
6576276
Compare
kishore7snehil
force-pushed
the
feat/obo-token-storage
branch
2 times, most recently
from
October 8, 2026 04:22
d57457d to
75faa2d
Compare
kishore7snehil
force-pushed
the
feat/m2m-client-credentials
branch
2 times, most recently
from
October 12, 2026 09:59
a9668aa to
0d427d9
Compare
nandan-bhat
previously approved these changes
Oct 22, 2026
kishore7snehil
force-pushed
the
feat/m2m-client-credentials
branch
from
October 22, 2026 06:41
398a6bf to
9349c8f
Compare
Add an ApiClient method to obtain a client credentials (M2M) access token for server-to-server calls using the OAuth 2.0 client credentials grant. The method authenticates via HTTP Basic and caches the result in a configured token_store keyed by audience and scope set, so a repeat call within the token's lifetime skips the network round-trip. Add the ClientCredentialsTokenResult type and GetClientCredentialsTokenError, and document the method in the README and examples.
Cache the scope Auth0 returned alongside the token and include it on a cache hit, so a hit matches the original exchange.
…aching Log the original exception through the module logger instead.
- Raise ApiError for a malformed token response instead of leaking ValueError or KeyError. - Cache token_type and return scope whenever it was saved, so a cache hit matches a fresh exchange. - Annotate the result as ClientCredentialsTokenResult. - Add tests for no token store, a different scope, a missing token endpoint, the SDK-side expiry check, and malformed responses.
kishore7snehil
force-pushed
the
feat/obo-token-storage
branch
from
October 22, 2026 06:52
5b9dcab to
1f4f105
Compare
kishore7snehil
force-pushed
the
feat/m2m-client-credentials
branch
from
October 22, 2026 06:52
9349c8f to
75290da
Compare
kishore7snehil
dismissed
nandan-bhat’s stale review
October 22, 2026 07:16
The base branch was changed.
nandan-bhat
approved these changes
Oct 22, 2026
Merged
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.
📋 Changes
This PR adds
get_client_credentials_token()toApiClientfor obtaining machine-to-machine access tokens with the OAuth 2.0 client credentials grant. When a token store is configured, the result is cached so repeat calls within the token's lifetime skip the network round-trip.✨ Features
get_client_credentials_token(audience, scope=None)method that authenticates with HTTP Basic using the configuredclient_idandclient_secret.token_storeis set, tokens are cached per tenant, client, audience, and scope set. Store read and write failures are logged and fall back to a fresh exchange.ClientCredentialsTokenResultTypedDict.🔧 API Changes
ApiClient.get_client_credentials_token()ClientCredentialsTokenResult(TypedDict)GetClientCredentialsTokenError, raised when client credentials are not configured or the token endpoint is missing from discovery metadata📖 Documentation
README.mdwith a client credentials sectionEXAMPLES.mdwith a client credentials example🧪 Testing
Contributor Checklist