openfga / openfga/java-sdk

Make client-credentials token refresh buffer and jitter configurable

Open
#388 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
54
Forks
26
Avg merge
2d 7h
Merged PRs (30d)
9

Description

Checklist
Describe the problem you'd like to have solved

In SDK 0.9.11, the client-credentials token expiry buffer is hardcoded to 300 seconds, plus 0–299 seconds of jitter. With Keycloak issuing 300-second access tokens, a freshly cached token is immediately considered stale. Sequential API calls therefore request new tokens instead of reusing them.

Describe the ideal solution

Allow configuring the refresh buffer and jitter, for example a 30-second buffer with a small jitter for five-minute tokens.

Alternatives and current workarounds

Increasing the Keycloak client's token lifetime avoids the mismatch, but requires longer-lived tokens to accommodate the SDK.

References

https://github.com/openfga/java-sdk/blob/v0.9.11/src/main/java/dev/openfga/sdk/api/auth/AccessToken.java

https://github.com/openfga/java-sdk/blob/v0.9.11/src/main/java/dev/openfga/sdk/constants/FgaConstants.java

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading src/main/java/dev/openfga/sdk/api/auth/AccessToken.java and src/main/java/dev/openfga/sdk/constants/FgaConstants.java, as referenced in the issue, to locate the hardcoded expiry buffer and jitter. Trace how client-credentials tokens are cached and refreshed, then make both values configurable and verify that five-minute tokens can be reused with a smaller buffer and jitter.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
authentication, authorization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.