feat: add client credentials grant support#335
Closed
aurel282 wants to merge 1 commit intobold-commerce:masterfrom
Closed
feat: add client credentials grant support#335aurel282 wants to merge 1 commit intobold-commerce:masterfrom
aurel282 wants to merge 1 commit intobold-commerce:masterfrom
Conversation
Implements OAuth 2.0 client credentials grant flow for server-to-server authentication with Shopify. Features: - GetClientCredentialsToken() for single token fetch - TokenManager for automatic token caching and refresh - Thread-safe concurrent access support - Configurable refresh buffer (default 1 hour before expiry) Shopify client credentials tokens expire after 24 hours. The TokenManager handles automatic refresh before expiry, making it suitable for long-running services like background jobs and cron tasks. See: https://shopify.dev/docs/apps/build/authentication-authorization/access-tokens/client-credentials-grant
Collaborator
|
I think this was already added recently in #333 ? |
Author
|
@oliver006 you are right. |
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.
Summary
This PR adds support for the OAuth 2.0 client credentials grant flow for server-to-server authentication with Shopify.
Features
GetClientCredentialsToken()- Fetches a single access token using client credentialsTokenManager- Manages automatic token caching and refresh for long-running servicesForceRefresh()for manual token refreshGetTokenInfo()for monitoring token stateClearToken()to invalidate cached tokenUse Case
The client credentials grant is designed for server-to-server authentication where user interaction is not possible, such as:
Note: The app must already be installed in the shop to use this flow.
Token Lifecycle
Shopify client credentials tokens expire after 24 hours. The
TokenManagerautomatically handles refresh before expiry, making it suitable for services that need continuous API access.Documentation
Testing
All new functionality includes comprehensive unit tests covering: