Skip to content

Commit

Permalink
Merge pull request #389
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Oct 28, 2017
2 parents 9b0ace2 + 4849619 commit e675435
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/main/java/org/kohsuke/github/GitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ public static GitHub connect() throws IOException {
return GitHubBuilder.fromCredentials().build();
}

/**
* Version that connects to GitHub Enterprise.
*
* @deprecated
* Use {@link #connectToEnterpriseWithOAuth(String, String, String)}
*/
public static GitHub connectToEnterprise(String apiUrl, String oauthAccessToken) throws IOException {
return connectToEnterpriseWithOAuth(apiUrl,null,oauthAccessToken);
}

/**
* Version that connects to GitHub Enterprise.
*
Expand All @@ -174,10 +184,16 @@ public static GitHub connect() throws IOException {
* "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has <tt>/api/v3</tt> in the URL.
* For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated.
*/
public static GitHub connectToEnterprise(String apiUrl, String oauthAccessToken) throws IOException {
return new GitHubBuilder().withEndpoint(apiUrl).withOAuthToken(oauthAccessToken).build();
public static GitHub connectToEnterpriseWithOAuth(String apiUrl, String login, String oauthAccessToken) throws IOException {
return new GitHubBuilder().withEndpoint(apiUrl).withOAuthToken(oauthAccessToken, login).build();
}

/**
* Version that connects to GitHub Enterprise.
*
* @deprecated
* Use with caution. Login with password is not a preferred method.
*/
public static GitHub connectToEnterprise(String apiUrl, String login, String password) throws IOException {
return new GitHubBuilder().withEndpoint(apiUrl).withPassword(login, password).build();
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/kohsuke/github/GitHubBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ public static GitHubBuilder fromProperties(Properties props) {
return self;
}

/**
* @param endpoint
* The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or
* "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has <tt>/api/v3</tt> in the URL.
* For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated.
*/
public GitHubBuilder withEndpoint(String endpoint) {
this.endpoint = endpoint;
return this;
Expand Down

0 comments on commit e675435

Please sign in to comment.