From a35f93fcaffe4b235b192890e9654d4d0fcf85c6 Mon Sep 17 00:00:00 2001 From: Marcos Eliziario Santos Date: Thu, 21 Oct 2021 09:19:02 -0300 Subject: [PATCH] Java OAuth refactors (#7239) --- .../io/airbyte/oauth/OAuthImplementationFactory.java | 2 +- .../java/io/airbyte/oauth/flows/SalesforceOAuthFlow.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/airbyte-oauth/src/main/java/io/airbyte/oauth/OAuthImplementationFactory.java b/airbyte-oauth/src/main/java/io/airbyte/oauth/OAuthImplementationFactory.java index 6f75b7d6be88..218e2c59f2b2 100644 --- a/airbyte-oauth/src/main/java/io/airbyte/oauth/OAuthImplementationFactory.java +++ b/airbyte-oauth/src/main/java/io/airbyte/oauth/OAuthImplementationFactory.java @@ -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; diff --git a/airbyte-oauth/src/main/java/io/airbyte/oauth/flows/SalesforceOAuthFlow.java b/airbyte-oauth/src/main/java/io/airbyte/oauth/flows/SalesforceOAuthFlow.java index e7b9d7633f30..5790999ba005 100644 --- a/airbyte-oauth/src/main/java/io/airbyte/oauth/flows/SalesforceOAuthFlow.java +++ b/airbyte-oauth/src/main/java/io/airbyte/oauth/flows/SalesforceOAuthFlow.java @@ -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 { @@ -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; } @@ -63,13 +64,13 @@ protected Map getAccessTokenQueryParameters(String clientId, Str } @Override - protected Map extractRefreshToken(JsonNode data) throws IOException { + protected Map 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)); } }