Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e38eeae

Browse filesBrowse files
author
watsonian
committed
Update constructor to use OAuth tokens rather than API tokens.
1 parent 8442e7e commit e38eeae
Copy full SHA for e38eeae

File tree

Expand file treeCollapse file tree

1 file changed

+14
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-14
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GitHub.java
+14-14Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class GitHub {
6666
private final Map<String,GHUser> users = new HashMap<String, GHUser>();
6767
private final Map<String,GHOrganization> orgs = new HashMap<String, GHOrganization>();
6868
/*package*/ String oauthAccessToken;
69-
69+
7070
private final String apiUrl;
7171

7272
private GitHub(String login, String apiToken, String password) {
@@ -81,14 +81,14 @@ private GitHub(String login, String apiToken, String password) {
8181
* For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated.
8282
* Password is also considered deprecated as it is no longer required for api usage.
8383
*/
84-
private GitHub(String apiUrl, String login, String apiToken, String password) {
84+
private GitHub(String apiUrl, String login, String oauthAccessToken, String password) {
8585
if (apiUrl.endsWith("/")) apiUrl = apiUrl.substring(0, apiUrl.length()-1); // normalize
8686
this.apiUrl = apiUrl;
87-
this.login = login;
88-
this.apiToken = apiToken;
87+
this.login = login;
88+
this.oauthAccessToken = oauthAccessToken;
8989

90-
if (apiToken!=null || password!=null) {
91-
String authorization = password==null ? (login + "/token" + ":" + apiToken) : (login + ':'+password);
90+
if (password!=null) {
91+
String authorization = (login + ':' + password);
9292
encodedAuthorization = new String(Base64.encodeBase64(authorization.getBytes()));
9393
} else
9494
encodedAuthorization = null;
@@ -97,14 +97,14 @@ private GitHub(String apiUrl, String login, String apiToken, String password) {
9797
private GitHub (String apiUrl, String oauthAccessToken) throws IOException {
9898
if (apiUrl.endsWith("/")) apiUrl = apiUrl.substring(0, apiUrl.length()-1); // normalize
9999
this.apiUrl = apiUrl;
100-
this.encodedAuthorization = null;
101-
102-
this.oauthAccessToken = oauthAccessToken;
100+
this.encodedAuthorization = null;
101+
102+
this.oauthAccessToken = oauthAccessToken;
103103
this.apiToken = oauthAccessToken;
104-
105-
this.login = getMyself().getLogin();
104+
105+
this.login = getMyself().getLogin();
106106
}
107-
107+
108108
/**
109109
* Obtains the credential from "~/.github"
110110
*/
@@ -147,7 +147,7 @@ public static GitHub connect(String login, String apiToken, String password){
147147
public static GitHub connectUsingOAuth (String accessToken) throws IOException {
148148
return connectUsingOAuth("github.com", accessToken);
149149
}
150-
150+
151151
public static GitHub connectUsingOAuth (String githubServer, String accessToken) throws IOException {
152152
return new GitHub(githubServer, accessToken);
153153
}
@@ -292,7 +292,7 @@ public <T extends GHEventPayload> T parseEventPayload(Reader r, Class<T> type) t
292292
t.wrapUp(this);
293293
return t;
294294
}
295-
295+
296296
/**
297297
* Creates a new repository.
298298
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.