Skip to content

Commit

Permalink
Java OAuth refactors (#7239)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliziario authored Oct 21, 2021
1 parent dfdbda8 commit a35f93f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import com.google.common.collect.ImmutableMap;
import io.airbyte.config.persistence.ConfigRepository;
import io.airbyte.oauth.flows.AsanaOAuthFlow;
import io.airbyte.oauth.flows.SalesforceOAuthFlow;
import io.airbyte.oauth.flows.FacebookMarketingOAuthFlow;
import io.airbyte.oauth.flows.SalesforceOAuthFlow;
import io.airbyte.oauth.flows.TrelloOAuthFlow;
import io.airbyte.oauth.flows.google.GoogleAdsOAuthFlow;
import io.airbyte.oauth.flows.google.GoogleAnalyticsOAuthFlow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import org.apache.http.client.utils.URIBuilder;

/**
* Following docs from https://help.salesforce.com/s/articleView?language=en_US&id=sf.remoteaccess_oauth_web_server_flow.htm
* Following docs from
* https://help.salesforce.com/s/articleView?language=en_US&id=sf.remoteaccess_oauth_web_server_flow.htm
*/
public class SalesforceOAuthFlow extends BaseOAuthFlow {

Expand Down Expand Up @@ -50,7 +51,7 @@ protected String formatConsentUrl(UUID definitionId, String clientId, String red
}

@Override
protected String getAccessTokenUrl() {
protected String getAccessTokenUrl(JsonNode oAuthConfig) {
return ACCESS_TOKEN_URL;
}

Expand All @@ -63,13 +64,13 @@ protected Map<String, String> getAccessTokenQueryParameters(String clientId, Str
}

@Override
protected Map<String, Object> extractRefreshToken(JsonNode data) throws IOException {
protected Map<String, Object> extractRefreshToken(JsonNode data, String accessTokenUrl) throws IOException {
System.out.println(Jsons.serialize(data));
if (data.has("refresh_token")) {
final String refreshToken = data.get("refresh_token").asText();
return Map.of("refresh_token", refreshToken);
} else {
throw new IOException(String.format("Missing 'refresh_token' in query params from %s", ACCESS_TOKEN_URL));
throw new IOException(String.format("Missing 'refresh_token' in query params from %s", accessTokenUrl));
}
}

Expand Down

0 comments on commit a35f93f

Please sign in to comment.