Conversation
Added specialized exceptions for different OAuth token refresh failure scenarios: - InvalidGrantException - for invalid/expired refresh tokens (requires user re-authorization) - PortalDomainNotFoundException - for non-existent or inaccessible portals Improved ApiClient::getNewAuthToken() method: - Replaced generic error messages with specific exception types based on HTTP status codes - Added detailed error handling for different OAuth error codes (invalid_grant, invalid_client, etc.) - Enhanced error messages with both OAuth error code and description - Added support for HTTP 400, 401, 404, and 5xx status codes - Developers can now distinguish between different failure causes and implement specific recovery logic Added comprehensive unit tests: - Tests for all new exception types - Tests for different HTTP status codes and OAuth error scenarios - Success case test for token refresh Updated CHANGELOG.md with details about the improvements. Resolves: #284
- Apply Rector code quality improvements (UnwrapSprintfOneArgumentRector, RenameVariableToMatchMethodCallReturnTypeRector) - Fix testGetNewAuthTokenSuccess: add required 'expires' field to mock response - Rename test parameter from $expectedException to $throwable for consistency - All unit tests pass (522 tests, 921 assertions)
Centralized OAuth token refresh error handling by moving logic from ApiClient::getNewAuthToken() to a new ApiLevelErrorHandler::handleOAuthError() method. Changes: - Added ApiLevelErrorHandler::handleOAuthError() method for centralized OAuth error handling - Simplified ApiClient::getNewAuthToken() from ~120 lines to ~20 lines - Method now delegates all error handling to ApiLevelErrorHandler - Improved code maintainability and reduced duplication - Added 'never' return type to handleOAuthError() for PHPStan compatibility Benefits: - Single source of truth for OAuth error handling logic - Easier to maintain and test error handling - Consistent error handling patterns across the SDK - Better separation of concerns All tests pass (522 tests, 921 assertions) All linters pass (PHP CS Fixer, PHPStan, Rector) Related: #284
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.
Added specialized exceptions for different OAuth token refresh failure scenarios:
Improved ApiClient::getNewAuthToken() method:
Added comprehensive unit tests:
Updated CHANGELOG.md with details about the improvements.
Resolves: #284