Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple Github API client using Groovy RESTClient
* Simple Github API client that supports basic auth.
class GithubClient {
String username
String password
String owner
String repository
String fetchFileContents(String filePath) {
public Map request(String url) {
githubApi.get(path : url).responseData
private String getRepoUrl() {
private RESTClient getGithubApi() {
return new RESTClient("").with {
headers.'User-Agent' = 'Mozilla/5.0'
if (username && password) {
headers['Authorization'] = 'Basic '+"${username}:${password}".getBytes('iso-8859-1').encodeBase64()
Copy link

You might also consider using the new Personal API Tokens so you don't have to embed your username and password:

Copy link

Here's the script that I use to generate weekly summary emails of Github issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment