2015-07-20 45 views
3

我一直在使用jcabi,GitHub的下面尝试是我的代码如何使用java连接到我公司的git hub门户?

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

但这给错误

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

我试图连接到我的公司是https://github.corp.xyz.com/

git的枢纽账户任何帮助?

+0

的消息说坏证书和代码表明没有凭据。 jcabi-github的javadoc似乎也没有任何有关身份验证的信息。除非有充分的理由,否则我会联系开发人员,询问如何进行身份验证。 – psycotik

+0

这是用于验证的代码的一部分。 Github github =新RtGithub(“”)在他们的网站/博客上阅读,我可以通过用户名/密码aur OAuth令牌 – Pratik

+0

尝试使用用户名/密码 – psycotik

回答

2

我以https://github.com/kohsuke/github-api

做到了这一点这里是供将来参考代码:

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

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