Skip to content

Commit e675435

Browse files
committed
Merge pull request hub4j#389
2 parents 9b0ace2 + 4849619 commit e675435

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/main/java/org/kohsuke/github/GitHub.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ public static GitHub connect() throws IOException {
166166
return GitHubBuilder.fromCredentials().build();
167167
}
168168

169+
/**
170+
* Version that connects to GitHub Enterprise.
171+
*
172+
* @deprecated
173+
* Use {@link #connectToEnterpriseWithOAuth(String, String, String)}
174+
*/
175+
public static GitHub connectToEnterprise(String apiUrl, String oauthAccessToken) throws IOException {
176+
return connectToEnterpriseWithOAuth(apiUrl,null,oauthAccessToken);
177+
}
178+
169179
/**
170180
* Version that connects to GitHub Enterprise.
171181
*
@@ -174,10 +184,16 @@ public static GitHub connect() throws IOException {
174184
* "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has <tt>/api/v3</tt> in the URL.
175185
* For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated.
176186
*/
177-
public static GitHub connectToEnterprise(String apiUrl, String oauthAccessToken) throws IOException {
178-
return new GitHubBuilder().withEndpoint(apiUrl).withOAuthToken(oauthAccessToken).build();
187+
public static GitHub connectToEnterpriseWithOAuth(String apiUrl, String login, String oauthAccessToken) throws IOException {
188+
return new GitHubBuilder().withEndpoint(apiUrl).withOAuthToken(oauthAccessToken, login).build();
179189
}
180190

191+
/**
192+
* Version that connects to GitHub Enterprise.
193+
*
194+
* @deprecated
195+
* Use with caution. Login with password is not a preferred method.
196+
*/
181197
public static GitHub connectToEnterprise(String apiUrl, String login, String password) throws IOException {
182198
return new GitHubBuilder().withEndpoint(apiUrl).withPassword(login, password).build();
183199
}

src/main/java/org/kohsuke/github/GitHubBuilder.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ public static GitHubBuilder fromProperties(Properties props) {
154154
return self;
155155
}
156156

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

0 commit comments

Comments
 (0)