Skip to content

Commit 8b149e8

Browse files
author
Baz
authored
🎉 Source Shopify: implement Oauth2.0 for Airbyte-Cloud (#9591)
1 parent 9d224f2 commit 8b149e8

File tree

15 files changed

+270
-78
lines changed

15 files changed

+270
-78
lines changed

airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/9da77001-af33-4bcd-be46-6252bf9342b9.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"sourceDefinitionId": "9da77001-af33-4bcd-be46-6252bf9342b9",
33
"name": "Shopify",
44
"dockerRepository": "airbyte/source-shopify",
5-
"dockerImageTag": "0.1.27",
5+
"dockerImageTag": "0.1.28",
66
"documentationUrl": "https://docs.airbyte.io/integrations/sources/shopify",
77
"icon": "shopify.svg"
88
}

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@
641641
- name: Shopify
642642
sourceDefinitionId: 9da77001-af33-4bcd-be46-6252bf9342b9
643643
dockerRepository: airbyte/source-shopify
644-
dockerImageTag: 0.1.27
644+
dockerImageTag: 0.1.28
645645
documentationUrl: https://docs.airbyte.io/integrations/sources/shopify
646646
icon: shopify.svg
647647
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6684,7 +6684,7 @@
66846684
supportsNormalization: false
66856685
supportsDBT: false
66866686
supported_destination_sync_modes: []
6687-
- dockerImage: "airbyte/source-shopify:0.1.27"
6687+
- dockerImage: "airbyte/source-shopify:0.1.28"
66886688
spec:
66896689
documentationUrl: "https://docs.airbyte.io/integrations/sources/shopify"
66906690
connectionSpecification:
@@ -6694,8 +6694,8 @@
66946694
required:
66956695
- "shop"
66966696
- "start_date"
6697-
- "auth_method"
6698-
additionalProperties: false
6697+
- "credentials"
6698+
additionalProperties: true
66996699
properties:
67006700
shop:
67016701
type: "string"
@@ -6710,24 +6710,21 @@
67106710
examples:
67116711
- "2021-01-01"
67126712
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
6713-
auth_method:
6713+
credentials:
67146714
title: "Shopify Authorization Method"
67156715
type: "object"
67166716
oneOf:
67176717
- type: "object"
67186718
title: "OAuth2.0"
67196719
required:
6720-
- "client_id"
6721-
- "client_secret"
6722-
- "access_token"
67236720
- "auth_method"
67246721
properties:
67256722
auth_method:
67266723
type: "string"
6727-
const: "access_token"
6724+
const: "oauth2.0"
67286725
enum:
6729-
- "access_token"
6730-
default: "access_token"
6726+
- "oauth2.0"
6727+
default: "oauth2.0"
67316728
order: 0
67326729
client_id:
67336730
type: "string"
@@ -6747,8 +6744,8 @@
67476744
- title: "API Password"
67486745
type: "object"
67496746
required:
6750-
- "api_password"
67516747
- "auth_method"
6748+
- "api_password"
67526749
properties:
67536750
auth_method:
67546751
type: "string"
@@ -6766,17 +6763,52 @@
67666763
supportsNormalization: false
67676764
supportsDBT: false
67686765
supported_destination_sync_modes: []
6769-
authSpecification:
6770-
auth_type: "oauth2.0"
6771-
oauth2Specification:
6772-
rootObject:
6773-
- "auth_method"
6774-
- "0"
6775-
oauthFlowInitParameters:
6776-
- - "client_id"
6777-
- - "client_secret"
6778-
oauthFlowOutputParameters:
6779-
- - "access_token"
6766+
advanced_auth:
6767+
auth_flow_type: "oauth2.0"
6768+
predicate_key:
6769+
- "credentials"
6770+
- "auth_method"
6771+
predicate_value: "oauth2.0"
6772+
oauth_config_specification:
6773+
oauth_user_input_from_connector_config_specification:
6774+
type: "object"
6775+
additionalProperties: false
6776+
properties:
6777+
shop:
6778+
type: "string"
6779+
path_in_connector_config:
6780+
- "shop"
6781+
complete_oauth_output_specification:
6782+
type: "object"
6783+
additionalProperties: false
6784+
properties:
6785+
access_token:
6786+
type: "string"
6787+
path_in_connector_config:
6788+
- "credentials"
6789+
- "access_token"
6790+
complete_oauth_server_input_specification:
6791+
type: "object"
6792+
additionalProperties: false
6793+
properties:
6794+
client_id:
6795+
type: "string"
6796+
client_secret:
6797+
type: "string"
6798+
complete_oauth_server_output_specification:
6799+
type: "object"
6800+
additionalProperties: false
6801+
properties:
6802+
client_id:
6803+
type: "string"
6804+
path_in_connector_config:
6805+
- "credentials"
6806+
- "client_id"
6807+
client_secret:
6808+
type: "string"
6809+
path_in_connector_config:
6810+
- "credentials"
6811+
- "client_secret"
67806812
- dockerImage: "airbyte/source-shortio:0.1.2"
67816813
spec:
67826814
documentationUrl: "https://developers.short.io/reference"

airbyte-integrations/connectors/destination-bigquery/src/main/java/io/airbyte/integrations/destination/bigquery/BigQueryUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package io.airbyte.integrations.destination.bigquery;
66

77
import static io.airbyte.integrations.destination.bigquery.helpers.LoggerHelper.getJobErrorMessage;
8-
import static java.util.Objects.isNull;
98

109
import com.fasterxml.jackson.databind.JsonNode;
1110
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -172,9 +171,9 @@ public static String getDatasetId(final JsonNode config) {
172171
String projectId = config.get(BigQueryConsts.CONFIG_PROJECT_ID).asText();
173172
if (!(projectId.equals(projectIdPart))) {
174173
throw new IllegalArgumentException(String.format(
175-
"Project ID included in Dataset ID must match Project ID field's value: Project ID is `%s`, but you specified `%s` in Dataset ID",
176-
projectId,
177-
projectIdPart));
174+
"Project ID included in Dataset ID must match Project ID field's value: Project ID is `%s`, but you specified `%s` in Dataset ID",
175+
projectId,
176+
projectIdPart));
178177
}
179178
}
180179
// if colonIndex is -1, then this returns the entire string

airbyte-integrations/connectors/destination-bigquery/src/test-integration/java/io/airbyte/integrations/destination/bigquery/BigQueryDestinationTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ private boolean isTablePartitioned(final BigQuery bigquery, final Dataset datase
385385
}
386386

387387
private static class DatasetIdResetter {
388+
388389
private Consumer<JsonNode> consumer;
389390

390391
DatasetIdResetter(Consumer<JsonNode> consumer) {
@@ -394,20 +395,20 @@ private static class DatasetIdResetter {
394395
public void accept(JsonNode config) {
395396
consumer.accept(config);
396397
}
398+
397399
}
398400

399401
private static Stream<Arguments> datasetIdResetterProvider() {
400402
// parameterized test with two dataset-id patterns: `dataset_id` and `project-id:dataset_id`
401403
return Stream.of(
402-
Arguments.arguments(new DatasetIdResetter(config -> {})),
403-
Arguments.arguments(new DatasetIdResetter(
404-
config -> {
405-
String projectId = ((ObjectNode) config).get(BigQueryConsts.CONFIG_PROJECT_ID).asText();
406-
String datasetId = ((ObjectNode) config).get(BigQueryConsts.CONFIG_DATASET_ID).asText();
407-
((ObjectNode) config).put(BigQueryConsts.CONFIG_DATASET_ID,
408-
String.format("%s:%s", projectId, datasetId));
409-
}
410-
))
411-
);
404+
Arguments.arguments(new DatasetIdResetter(config -> {})),
405+
Arguments.arguments(new DatasetIdResetter(
406+
config -> {
407+
String projectId = ((ObjectNode) config).get(BigQueryConsts.CONFIG_PROJECT_ID).asText();
408+
String datasetId = ((ObjectNode) config).get(BigQueryConsts.CONFIG_DATASET_ID).asText();
409+
((ObjectNode) config).put(BigQueryConsts.CONFIG_DATASET_ID,
410+
String.format("%s:%s", projectId, datasetId));
411+
})));
412412
}
413+
413414
}

airbyte-integrations/connectors/destination-bigquery/src/test/java/io/airbyte/integrations/destination/bigquery/BigQueryUtilsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void init() {
2626
.put(BigQueryConsts.CONFIG_CREDS, "test_secret")
2727
.put(BigQueryConsts.CONFIG_DATASET_LOCATION, "US");
2828
}
29-
29+
3030
@ParameterizedTest
3131
@MethodSource("validBigQueryIdProvider")
3232
public void testGetDatasetIdSuccess(String projectId, String datasetId, String expected) throws Exception {
@@ -66,4 +66,5 @@ private static Stream<Arguments> invalidBigQueryIdProvider() {
6666
Arguments.arguments("my-project", "your-project:my_dataset",
6767
"Project ID included in Dataset ID must match Project ID field's value: Project ID is `my-project`, but you specified `your-project` in Dataset ID"));
6868
}
69+
6970
}

airbyte-integrations/connectors/source-shopify/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ COPY source_shopify ./source_shopify
2828
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
2929
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
3030

31-
LABEL io.airbyte.version=0.1.27
31+
LABEL io.airbyte.version=0.1.28
3232
LABEL io.airbyte.name=airbyte/source-shopify

airbyte-integrations/connectors/source-shopify/integration_tests/invalid_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"shop": "SHOP_NAME",
33
"start_date": "2020-11-01",
4-
"auth_method": {
4+
"credentials": {
55
"auth_method": "api_password",
66
"api_password": "SOME_API_PASSWORD"
77
}

airbyte-integrations/connectors/source-shopify/integration_tests/invalid_oauth_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"shop": "SHOP_NAME",
33
"start_date": "2020-11-01",
4-
"auth_method": {
5-
"auth_method": "access_token",
4+
"credentials": {
5+
"auth_method": "oauth2.0",
66
"client_id": "SOME_CLIENT_ID",
77
"client_secret": "SOME_CLIENT_SECRET",
88
"access_token": "SOME_ACCESS_TOKEN"

airbyte-integrations/connectors/source-shopify/source_shopify/auth.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ def __init__(self, config: Mapping[str, Any]):
3030
def get_auth_header(self) -> Mapping[str, Any]:
3131

3232
auth_header: str = "X-Shopify-Access-Token"
33-
auth_method: Dict = self.config["auth_method"]
34-
auth_option: str = auth_method.get("auth_method")
33+
credentials: Dict = self.config["credentials"]
34+
auth_method: str = credentials.get("auth_method")
3535

36-
if auth_option == "access_token":
37-
return {auth_header: auth_method.get("access_token")}
38-
elif auth_option == "api_password":
39-
return {auth_header: auth_method.get("api_password")}
36+
if auth_method == "oauth2.0":
37+
return {auth_header: credentials.get("access_token")}
38+
elif auth_method == "api_password":
39+
return {auth_header: credentials.get("api_password")}
4040
else:
41-
raise NotImplementedAuth(auth_option)
41+
raise NotImplementedAuth(auth_method)

0 commit comments

Comments
 (0)