How can I connect to my company's git hub portal using java?

336 Views Asked by At

I have tried using jcabi-github following is my code

Github github = new RtGithub("<Oauth token>");
Iterable<Repo> repo =  github.repos().iterate("");
for (Repo repo2 : repo) {
    System.out.println(repo2);
}

But this is giving error

{"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}>
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)

I am trying to connect to my company's git hub account which is https://github.corp.xyz.com/

Any help?

1

There are 1 best solutions below

0
On

I have done this by using https://github.com/kohsuke/github-api

Here is the code for future reference:

GitHub github = GitHub.connectToEnterprise(
                        "https://github.corp.<abc>.com/api/v3",
                        "<Oauth token>");

GHContentSearchBuilder search = github.searchContent();
GHContentSearchBuilder s = search.q(<searchkeyword>);