【问题标题】:How can I connect to my company's git hub portal using java?如何使用 java 连接到我公司的 git hub 门户?
【发布时间】:2015-10-09 03:14:16
【问题描述】:

我尝试过使用 jcabi-github 以下是我的代码

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)

我正在尝试连接到我公司的 git hub 帐户 https://github.corp.xyz.com/

有什么帮助吗?

【问题讨论】:

  • 消息说凭据错误,代码显示没有凭据。 jcabi-github 的 javadocs 似乎也没有任何关于身份验证的信息。除非有充分的理由,否则我会联系开发人员并询问您将如何进行身份验证。
  • 这是用于身份验证的代码部分。 Github github = new RtGithub("") 在他们的网站/博客上阅读,我可以通过用户名/密码 aur OAuth Token
  • 尝试使用用户名/密码,
  • 也尝试过使用用户名/密码
  • 如果您正在执行重复请求,您可能已经达到了限制,即使一切正常,也会导致“凭据错误”消息。稍等片刻,它就会消失;或使用其他帐户。

标签: java github github-api jcabi


【解决方案1】:

我已经通过使用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>);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-30
    • 1970-01-01
    • 2018-08-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多