2015-07-20 48 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>);