Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
make graphQL call with hygieia token if 401 when using collectorItemT…
Browse files Browse the repository at this point in the history
…oken (#118)
  • Loading branch information
dcanar9 authored Sep 23, 2022
1 parent 412dba4 commit 1f3f15f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</description>
<url>https://github.com/Hygieia/${repository.name}</url>
<packaging>jar</packaging>
<version>3.3.19-SNAPSHOT</version>
<version>3.3.20-SNAPSHOT</version>


<parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1344,16 +1344,21 @@ private JSONObject getDataFromRestCallPost(GitHubParsed gitHubParsed, GitHubRepo
}

private ResponseEntity<String> makeRestCallPost(String url, String userId, String password, String personalAccessToken, JSONObject query) {
ResponseEntity<String> response;
// Basic Auth only.
if (!Objects.equals("", userId) && !Objects.equals("", password)) {
RestUserInfo userInfo = new RestUserInfo(userId, password);
return restClient.makeRestCallPost(url, userInfo, query);
response = restClient.makeRestCallPost(url, userInfo, query);
} else if (personalAccessToken != null && !Objects.equals("", personalAccessToken)) {
return restClient.makeRestCallPost(url, "token", personalAccessToken, query);
response = restClient.makeRestCallPost(url, "token", personalAccessToken, query);
if (Objects.nonNull(response) && response.getStatusCode() != HttpStatus.OK) {
response = restClient.makeRestCallPost(url, "token", settings.getPersonalAccessToken(), query);
}
} else {
// This handles the case when settings.getPersonalAccessToken() is empty
return restClient.makeRestCallPost(url, "token", settings.getPersonalAccessToken(), query);
response = restClient.makeRestCallPost(url, "token", settings.getPersonalAccessToken(), query);
}
return response;
}

private ResponseEntity<String> makeRestCallGet(String url) throws RestClientException {
Expand Down

0 comments on commit 1f3f15f

Please sign in to comment.