bamaer opened a new issue, #9550:
URL: https://github.com/apache/hop/issues/9550

   ### What would you like to happen?
   
   A REST connection with OAuth 2 authentication caches its access token for 
the whole JVM until shortly before `expires_in` 
([RestOAuth2TokenProvider.java:60](https://github.com/apache/hop/blob/39b3d636b2e003ab9e857eb385f549cbc3e9248c/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/client/RestOAuth2TokenProvider.java#L60)).
 If the server rejects that token earlier — revoked, rotated, or invalidated 
because another client requested a new one — every following request gets a 401 
until the token's expiry time passes or Hop GUI / Hop Server is restarted.
   
   `RestOAuth2TokenProvider.invalidate()` ([line 
113](https://github.com/apache/hop/blob/39b3d636b2e003ab9e857eb385f549cbc3e9248c/plugins/misc/rest/src/main/java/org/apache/hop/metadata/rest/client/RestOAuth2TokenProvider.java#L113))
 exists for this case, but only a unit test calls it. Adding 401 to the 
transform's retry status codes does not help: `executeWithRetry` resends the 
request with the same cached token.
   
   Proposal:
   
   - When a request authenticated with an OAuth 2 token gets a 401, invalidate 
the cached token, fetch a new one and retry the request once. A second 401 is 
reported as it is today.
   - Apply this to every caller of the REST connection's client (REST 
transform, including pagination, and the connection test).
   - For a Bearer connection, a 401 cannot be fixed by Hop. Log a short hint 
that tokens which expire need the OAuth 2 authentication type.
   
   Tests: a WireMock-based unit test in `plugins/misc/rest` with a stateful 
scenario: the token endpoint issues token 1, the API accepts it for two 
requests and then answers 401, the token endpoint issues token 2, and the 
following requests succeed.
   
   ### Issue Priority
   
   Priority: 2
   
   ### Issue Component
   
   Component: Metadata, Component: Transforms
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to