Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to cache installation tokens? #57

Open
bbaga opened this issue Apr 15, 2021 · 0 comments
Open

Question: How to cache installation tokens? #57

bbaga opened this issue Apr 15, 2021 · 0 comments

Comments

@bbaga
Copy link

bbaga commented Apr 15, 2021

The readme says:

The client will manage the generation of JWT tokens, as well as requesting and caching the installation tokens from GitHub.

I see that there is a hash map for the installation tokens, but I couldn't figure out how to make the client object remember more than one token.

Here is what I tried to do:

  1. create a new github client instance with the private key and app id combo
  2. periodically (1 minute) Iterate through a list of repositories that are all under the same installation
    2.1. get the installation id for the repository with:
    client.createRepositoryClient(owner, repo).createGithubAppClient().getInstallation().get().id()
    2.2 use GitHubClient.scopeForInstallationId(...) to authenticate as an installation and this is where the library checks for the installation token and I see the following in the logs Github token for installation 14XXXXXX is either expired or null. Trying to get a new one. for every repository in every iteration.

After looking at the code, I'm not sure how the caching should work when the scopeForInstallationId(...) returns a new GitHubClient instance so I assume the hash map with the installation tokens will be empty.

I'm not very good with java so my assumption is I'm doing something wrong, can you give me some pointers?

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

No branches or pull requests

1 participant