Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck committed Mar 8, 2024
1 parent fbe068d commit e184048
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/main/java/io/jenkins/update_center/GitHubSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@ protected void initializeOrganizationData(String organization) throws IOExceptio
this.repoNames = new TreeSet<>(String::compareToIgnoreCase);

LOGGER.log(Level.INFO, "Retrieving GitHub repo data...");
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (GITHUB_API_USERNAME != null && GITHUB_API_PASSWORD != null) {
builder.authenticator((route, response) -> {
String credential = Credentials.basic(GITHUB_API_USERNAME, GITHUB_API_PASSWORD);
return response.request().newBuilder().header("Authorization", credential).build();
});
}
OkHttpClient client = builder.build();
OkHttpClient client = new OkHttpClient.Builder().build();

boolean hasNextPage = true;
String endCursor = null;
Expand Down Expand Up @@ -106,10 +99,13 @@ protected void initializeOrganizationData(String organization) throws IOExceptio
));
LOGGER.log(Level.FINE, String.format("Retrieving GitHub topics with end token... %s", endCursor));

Request request = new Request.Builder()
Request.Builder builder = new Request.Builder()
.url(this.getGraphqlUrl())
.post(RequestBody.create(jsonObject.toString(), MediaType.parse("application/json; charset=utf-8")))
.build();
.post(RequestBody.create(jsonObject.toString(), MediaType.parse("application/json; charset=utf-8")));
if (GITHUB_API_PASSWORD != null && GITHUB_API_USERNAME != null) {
builder = builder.header("Authorization", Credentials.basic(GITHUB_API_USERNAME, GITHUB_API_PASSWORD));
}
Request request = builder.build();

String bodyString = HttpHelper.getResponseBody(client, request);

Expand Down

0 comments on commit e184048

Please sign in to comment.