Title: feat: Add repository-scoped token support to GithubAppClient by PhoebeMay · Pull Request #258 · spotify/github-java-client · GitHub
Open Graph Title: feat: Add repository-scoped token support to GithubAppClient by PhoebeMay · Pull Request #258 · spotify/github-java-client
X Title: feat: Add repository-scoped token support to GithubAppClient by PhoebeMay · Pull Request #258 · spotify/github-java-client
Description: Summary
Adds support for creating repository-scoped installation access tokens via the GitHub Apps API. This allows tokens to be
restricted to specific repositories instead of granting access to all repositories in an installation.
This is an implementation of https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app
API Usage
// Create a scoped token for specific repositories
AccessTokenRequest request = ImmutableAccessTokenRequest.builder()
.repositoryIds(List.of(313604, 314195))
.build();
AccessToken token = appClient.getAccessToken(installationId, request).join();
// Or scope by repository name
AccessTokenRequest request = ImmutableAccessTokenRequest.builder()
.repositories(List.of("my-repo"))
.build();
Testing
Unit Tests
All existing tests pass, plus 3 new test cases:
✅ getAccessTokenWithoutScoping - Verifies backward compatibility (empty body)
✅ getAccessTokenWithRepositoryScoping - Verifies scoped token creation with both repositories and repository_ids
✅ getAccessTokenWithEmptyRequest - Verifies empty request serializes to {}
Manual Testing
Verified end-to-end with GitHub Enterprise Server:
Test 1: Unscoped Token (`Old Behavior)
Created token using existing getAccessToken(installationId) method
GithubAppClient appClient = client.createGithubAppClient();
AccessToken unscopedToken = appClient.getAccessToken(installationId).join();
Verification via GitHub API:
curl -H 'Authorization: Bearer
Open Graph Description: Summary Adds support for creating repository-scoped installation access tokens via the GitHub Apps API. This allows tokens to be restricted to specific repositories instead of granting access to al...
X Description: Summary Adds support for creating repository-scoped installation access tokens via the GitHub Apps API. This allows tokens to be restricted to specific repositories instead of granting access to al...
Opengraph URL: https://github.com/spotify/github-java-client/pull/258
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:3508ca56-1027-ac28-e5bc-29383b18d8e0 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9BDE:10BDCB:12519AB:195F87F:69777316 |
| html-safe-nonce | 374de95a1ed2cd2593379876ffad7a857adac0bc2dca806e08b91a0a2e793aea |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkRFOjEwQkRDQjoxMjUxOUFCOjE5NUY4N0Y6Njk3NzczMTYiLCJ2aXNpdG9yX2lkIjoiMTUxMTA1MDU1OTcxNDk4MDYzMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9ecbe3b8ef89dfa70a1f322f5c6e8a1bb099390297e6303b5027b91ca800831f |
| hovercard-subject-tag | pull_request:3068591226 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/spotify/github-java-client/pull/258/files |
| twitter:image | https://avatars.githubusercontent.com/u/13728765?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/13728765?s=400&v=4 |
| og:image:alt | Summary Adds support for creating repository-scoped installation access tokens via the GitHub Apps API. This allows tokens to be restricted to specific repositories instead of granting access to al... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9fea6af76c6e24ca5c5728a18d4220d768790d04abe1ba6aafa18526daff96e7 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6c4a3fa336c0d96309887d0be819777cadd37121 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width