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

Documentation: Syntax error in Github.create

Open Black-Smith-Of-Fire opened this issue 9 months ago • 2 comments

The documentation requires a slight updation. Here we need to pass a URI in the second parameter of the method .

final GitHubClient githubClient = GitHubClient.create( URI.create("https://api.github.com/"), new File("/path-to-the/private-key.pem"), // here we need to convert the path to a URI APP_ID);

Black-Smith-Of-Fire avatar Mar 26 '25 10:03 Black-Smith-Of-Fire

Duplicating my comment in the PR here

The method is defined as

public static GitHubClient create(final URI baseUrl, final File privateKey, final Integer appId){}

There's no create overload (AFAIK) which accepts URI for the private key. There's one which takes byte[] instead.
Can you show the code where we are accepting URI instead of File?

Abhi347 avatar Mar 26 '25 15:03 Abhi347

I see what you mean at line number 191 in the com.spotify.github.v3.clients.GitHubClient class, but why can't I pass File in the second parameter ? Line number 179 is the create overload that I am talking about. We are using version number 0.4.1, right ?

Black-Smith-Of-Fire avatar Mar 27 '25 01:03 Black-Smith-Of-Fire

I don't think I follow. The private key is never accepted as a URI. Line 179 URI are the REST API and GraphQL API URLs, the last parameter is for access token in String format.

Abhi347 avatar Apr 05 '25 09:04 Abhi347

Ok I am sorry, there was an issue with my ide. The issue is resolved from my side. But thank you for taking your time ! Cheers !

Black-Smith-Of-Fire avatar Apr 14 '25 05:04 Black-Smith-Of-Fire