Skip to content

Commit

Permalink
Cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Jul 1, 2024
1 parent c2b5a16 commit 096b148
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public MsaCode applyStep(final ILogger logger, final HttpClient httpClient, fina
while (!msaDeviceCode.isExpired() && System.currentTimeMillis() - start <= this.timeout) {
final Map<String, String> postData = new HashMap<>();
postData.put("client_id", msaDeviceCode.getApplicationDetails().getClientId());
postData.put("device_code", msaDeviceCode.getDeviceCode());
postData.put("grant_type", "device_code");
postData.put("device_code", msaDeviceCode.getDeviceCode());

final PostRequest postRequest = new PostRequest(msaDeviceCode.getApplicationDetails().getOAuthEnvironment().getTokenUrl());
postRequest.setContent(new URLEncodedFormContent(postData));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ private MsaToken apply(final ILogger logger, final HttpClient httpClient, final
final Map<String, String> postData = new HashMap<>();
postData.put("client_id", applicationDetails.getClientId());
postData.put("scope", applicationDetails.getScope());
if (applicationDetails.getClientSecret() != null) {
postData.put("client_secret", applicationDetails.getClientSecret());
}
postData.put("grant_type", type);
if (type.equals("refresh_token")) {
postData.put("refresh_token", codeOrRefreshToken);
} else {
} else if (type.equals("authorization_code")) {
postData.put("code", codeOrRefreshToken);
postData.put("redirect_uri", applicationDetails.getRedirectUri());
}
if (applicationDetails.getClientSecret() != null) {
postData.put("client_secret", applicationDetails.getClientSecret());
} else {
throw new IllegalArgumentException("Invalid type: " + type);
}

final PostRequest postRequest = new PostRequest(applicationDetails.getOAuthEnvironment().getTokenUrl());
Expand Down

0 comments on commit 096b148

Please sign in to comment.