Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dheyman-1 committed Nov 30, 2024
1 parent 1741680 commit 119a205
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public String getAccessToken(SFLoginInput loginInput) throws SFException {
private AuthorizationCode requestAuthorizationCode(SFLoginInput loginInput) throws SFException {
try {
AuthorizationRequest request = buildAuthorizationRequest(loginInput);

URI requestURI = request.toURI();
HttpUtil.executeGeneralRequest(new HttpGet(requestURI),
loginInput.getLoginTimeout(),
Expand Down Expand Up @@ -92,9 +91,9 @@ private static CompletableFuture<String> getAuthorizationCodeFromRedirectURI() t
private static AuthorizationRequest buildAuthorizationRequest(SFLoginInput loginInput) throws URISyntaxException {
URI authorizeEndpoint = new URI(String.format("%s/oauth/authorize", loginInput.getServerUrl()));
ClientID clientID = new ClientID("123");
Scope scope = new Scope("read", "write");
Scope scope = new Scope(String.format("session:role:%s", loginInput.getRole()));
URI callback = buildRedirectURI();
State state = new State();
State state = new State(256);
return new AuthorizationRequest.Builder(
new ResponseType(ResponseType.Value.CODE), clientID)
.scope(scope)
Expand All @@ -111,10 +110,9 @@ private static URI buildRedirectURI() throws URISyntaxException {
private static TokenRequest buildTokenRequest(SFLoginInput loginInput, AuthorizationCode authorizationCode) throws URISyntaxException {
URI callback = buildRedirectURI();
AuthorizationGrant codeGrant = new AuthorizationCodeGrant(authorizationCode, callback);
ClientID clientID = new ClientID("123");
Secret clientSecret = new Secret("123");
ClientAuthentication clientAuthentication = new ClientSecretBasic(clientID, clientSecret);
URI tokenEndpoint = new URI(String.format("%s/oauth/token", loginInput.getServerUrl()));
return new TokenRequest(tokenEndpoint, clientAuthentication, codeGrant, new Scope());
ClientAuthentication clientAuthentication = new ClientSecretBasic(new ClientID("123"), new Secret("123"));
URI tokenEndpoint = new URI(String.format("%s/oauth/token-request", loginInput.getServerUrl()));
Scope scope = new Scope("session:role", loginInput.getRole());
return new TokenRequest(tokenEndpoint, clientAuthentication, codeGrant, scope);
}
}

0 comments on commit 119a205

Please sign in to comment.