github-java-client icon indicating copy to clipboard operation
github-java-client copied to clipboard

Support a way to only generate access tokens from installation

Open patricioperezv opened this issue 5 years ago • 1 comments

Hi, i'm playing with a use case in which i need to get an access token from a github application (appid and installation id), this access token is used to clone a repo, so i don't really need any more actions to be done on the github api (Besides getting the access token), i would really like to use this library for that purpose, is it possible? I tried the following:

GitHubClient hubClient = GitHubClient.create(
    URI.create(GITHUB_ENDPOINT),
    new File(pemLocation),
    applicationId,
    installationId
);

SearchClient searchClient = hubClient.createSearchClient();
searchClient.users(ImmutableSearchParameters.builder().q("dumbdumb").build());

Optional<String> accessToken = hubClient.getAccessToken();

But the access token doesn't get populated

patricioperezv avatar Dec 24 '20 01:12 patricioperezv

Hey, I don't think the Access Token is generated without making any request, so calling getAccessToken() will fail. The access token is generated here in case this helps you.

Abhi347 avatar Feb 05 '21 10:02 Abhi347