feat(core): Add configurable HTTP status code for OAuth2 token refresh#26641
Open
guillaumejacquart wants to merge 1 commit intomasterfrom
Open
feat(core): Add configurable HTTP status code for OAuth2 token refresh#26641guillaumejacquart wants to merge 1 commit intomasterfrom
guillaumejacquart wants to merge 1 commit intomasterfrom
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
No issues found across 4 files
Architecture diagram
sequenceDiagram
participant Node as Node Execution Engine
participant Creds as Credential Store
participant API as External API
participant OAuth as OAuth2 Provider
participant DB as Database (CredentialsHelper)
Note over Node, API: Initial Request Flow
Node->>Creds: getCredentials()
Creds-->>Node: OAuth2 Data (incl. NEW: tokenExpiredStatusCode)
Node->>Node: NEW: resolveTokenExpiredStatusCode()
Note right of Node: Priority: Credential Config > Node Options > 401
Node->>API: httpRequest() with Access Token
alt Success (2xx)
API-->>Node: Data
else CHANGED: Response Status == tokenExpiredStatusCode
API-->>Node: Error (e.g., 403 Forbidden)
Note over Node, OAuth: NEW: centralized refreshOrFetchToken flow
Node->>OAuth: Request new token (Refresh or Client Credentials)
OAuth-->>Node: New Access Token + Refresh Token
Node->>DB: updateCredentialsOauthTokenData()
DB-->>Node: Persisted
Node->>API: Retry httpRequest() with New Token
API-->>Node: Data
else Other Error Status
API-->>Node: Error Response
Node-->>Node: Throw ApplicationError
end
…f oauth access token
3542402 to
4769169
Compare
packages/core/src/execution-engine/node-execution-context/utils/request-helper-functions.ts
Show resolved
Hide resolved
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
Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/IAM-36
Review / Merge checklist
release/backport(if the PR is an urgent fix that needs to be backported)