2017-02-07 40 views

回答

0

以下片段顯示了原理。

String credtials = "github.credentials"; 
GitHub gitHub = GitHubBuilder.fromPropertyFile(credtials) 
     .withRateLimitHandler(RateLimitHandler.FAIL) 
     .build(); 
GHRepository repository = gitHub.getRepository("shaunlebron/api-docs"); 
for (GHRelease release : repository.listReleases()) { 
    System.out.println(release.getName()); 
    for (GHAsset a : release.getAssets()) { 
     System.out.println(" -> " + a.getName()); 
    } 
} 

假設該文件包含github.credentials

login=your_user_name 
password=your_access_token 

訪問令牌可以爲您的Github上的用戶在https://github.com/settings/tokens創建。

輸出

docs-release 
    -> cljsdocs-full.edn 
    -> cljsdocs-report.edn 

下載網址你GHAsset.getBrowserDownloadUrl()得到。

您可以在https://api.github.com/repos/shaunlebron/api-docs/releases(您需要登錄到Github)進行驗證。