Title: Question: How to cache installation tokens? · Issue #57 · spotify/github-java-client · GitHub
Open Graph Title: Question: How to cache installation tokens? · Issue #57 · spotify/github-java-client
X Title: Question: How to cache installation tokens? · Issue #57 · spotify/github-java-client
Description: 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 mak...
Open Graph Description: 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 toke...
X Description: 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 toke...
Opengraph URL: https://github.com/spotify/github-java-client/issues/57
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Question: How to cache installation tokens?","articleBody":"The readme says:\r\n\u003e The client will manage the generation of JWT tokens, as well as requesting **and caching the installation tokens** from GitHub.\r\n\r\nI see that there is a [hash map for the installation tokens](https://github.com/spotify/github-java-client/blob/v0.0.25/src/main/java/com/spotify/github/v3/clients/GitHubClient.java#L121), but I couldn't figure out how to make the client object remember more than one token.\r\n\r\nHere is what I tried to do:\r\n1. create a new github client instance with the private key and app id combo\r\n2. periodically (1 minute) Iterate through a list of repositories that are all under the same installation\r\n 2.1. get the installation id for the repository with:\r\n ```\r\n client.createRepositoryClient(owner, repo).createGithubAppClient().getInstallation().get().id()\r\n ```\r\n 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.\r\n\r\nAfter 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.\r\n\r\nI'm not very good with java so my assumption is I'm doing something wrong, can you give me some pointers?","author":{"url":"https://github.com/bbaga","@type":"Person","name":"bbaga"},"datePublished":"2021-04-15T09:17:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/57/github-java-client/issues/57"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:244ef4b1-951a-24aa-7f7b-e7fe48ffeaf6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6E8:1D9B97:E5DBD0A:12938066:6977101C |
| html-safe-nonce | 8deffe1789699eaf71d0f207728b975f8a9b0a755ab1c59b6c675fbb6fff5e35 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkU4OjFEOUI5NzpFNURCRDBBOjEyOTM4MDY2OjY5NzcxMDFDIiwidmlzaXRvcl9pZCI6IjI4NDU2MzUyMTM3MDg5NTU2NzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 41f4a6af1cf8bfa266cbccde27ec9591f078d302d966fac9b5f9c4d692a5706d |
| hovercard-subject-tag | issue:858678719 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/spotify/github-java-client/57/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b5974e2953ee298932508545dc9e9c3c51d7c9e290ae231c8d12293074eade0c/spotify/github-java-client/issues/57 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b5974e2953ee298932508545dc9e9c3c51d7c9e290ae231c8d12293074eade0c/spotify/github-java-client/issues/57 |
| og:image:alt | 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 toke... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bbaga |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01d198479908d09a841b2febe8eb105a81af2af7d81830960fe0971e1f4adc09 |
| turbo-cache-control | no-preview |
| go-import | github.com/spotify/github-java-client git https://github.com/spotify/github-java-client.git |
| octolytics-dimension-user_id | 251374 |
| octolytics-dimension-user_login | spotify |
| octolytics-dimension-repository_id | 254401089 |
| octolytics-dimension-repository_nwo | spotify/github-java-client |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 254401089 |
| octolytics-dimension-repository_network_root_nwo | spotify/github-java-client |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f752335dbbea672610081196a1998e39aec5e14b |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width