Skip to content

Question: How to cache installation tokens? #57

Open
@bbaga

Description

@bbaga

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions