Skip to content

feat: add optional SW360KeycloakClient with automatic token renewal - #72

Merged
tngraf merged 1 commit into
sw360:masterfrom
berke581:feat/keycloak-token-renewal
Nov 8, 2026
Merged

tngraf merged 1 commit into
sw360:masterfrom
berke581:feat/keycloak-token-renewal

Conversation

@berke581

@berke581 berke581 commented Nov 6, 2026

Copy link
Copy Markdown

Follow-up to the discussion in sw360/capycli#242 about where token refresh for long running operations should happen. (berke581@5da20c6)

SW360Keycloak (added in #51) can obtain a token, but SW360 only accepts a finished token and has no way to renew it. So when a token expires in the middle of a long run, the caller has to handle the refresh itself.

This adds an optional SW360KeycloakClient which takes client_id and client_secret instead of a token. It obtains the token, caches it, and requests a new one shortly before expiry — for session requests as well as for methods that read api_headers directly. Unless a session is passed in it creates its own, so the session shared by SW360 instances stays untouched.

SW360 and SW360Keycloak are unchanged, existing callers keep working as before.

client = SW360KeycloakClient(sw360_url, client_id, client_secret)
client.login_api()

Known limitation: expiry is taken from the exp claim, so a token revoked before it expires is not detected.

Happy to adjust it or to close this if you'd rather keep the refresh handling on the capycli side.

SW360 is given a finished token and cannot renew it, so operations
running longer than the token lifetime fail once it expires.

SW360KeycloakClient takes the Keycloak client_id and client_secret
instead and renews the token shortly before expiry. SW360 and
SW360Keycloak are unchanged, existing callers keep working as before.
@tngraf tngraf self-assigned this Nov 8, 2026
@tngraf
tngraf merged commit 73df5a3 into sw360:master Nov 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants