diff --git a/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/badc5925-0485-42be-8caa-b34096cb71b5.json b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/badc5925-0485-42be-8caa-b34096cb71b5.json index dab7a3814551..dcef89363a77 100644 --- a/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/badc5925-0485-42be-8caa-b34096cb71b5.json +++ b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/badc5925-0485-42be-8caa-b34096cb71b5.json @@ -2,6 +2,6 @@ "sourceDefinitionId": "badc5925-0485-42be-8caa-b34096cb71b5", "name": "Survey Monkey", "dockerRepository": "airbyte/source-surveymonkey", - "dockerImageTag": "0.1.0", + "dockerImageTag": "0.1.2", "documentationUrl": "https://docs.airbyte.io/integrations/sources/surveymonkey" } diff --git a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml index 2b41fd8bfca6..8e27b4c532df 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -512,7 +512,7 @@ - name: Survey Monkey sourceDefinitionId: badc5925-0485-42be-8caa-b34096cb71b5 dockerRepository: airbyte/source-surveymonkey - dockerImageTag: 0.1.0 + dockerImageTag: 0.1.2 documentationUrl: https://docs.airbyte.io/integrations/sources/surveymonkey sourceType: api - name: Tempo diff --git a/airbyte-integrations/connectors/source-surveymonkey/Dockerfile b/airbyte-integrations/connectors/source-surveymonkey/Dockerfile index cdc81916013d..70fceaea7ce6 100644 --- a/airbyte-integrations/connectors/source-surveymonkey/Dockerfile +++ b/airbyte-integrations/connectors/source-surveymonkey/Dockerfile @@ -12,5 +12,5 @@ RUN pip install . ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] -LABEL io.airbyte.version=0.1.1 +LABEL io.airbyte.version=0.1.2 LABEL io.airbyte.name=airbyte/source-surveymonkey diff --git a/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/source.py b/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/source.py index 62da51131d98..6073aa78cf59 100644 --- a/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/source.py +++ b/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/source.py @@ -17,7 +17,7 @@ class SourceSurveymonkey(AbstractSource): def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, Any]: try: - authenticator = TokenAuthenticator(token=config["access_token"]) + authenticator = self.get_authenticator(config) start_date = pendulum.parse(config["start_date"]) stream = Surveys(authenticator=authenticator, start_date=start_date) records = stream.read_records(sync_mode=SyncMode.full_refresh) @@ -27,7 +27,17 @@ def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> return False, repr(e) def streams(self, config: Mapping[str, Any]) -> List[Stream]: - authenticator = TokenAuthenticator(token=config["access_token"]) + authenticator = self.get_authenticator(config) start_date = pendulum.parse(config["start_date"]) args = {"authenticator": authenticator, "start_date": start_date} return [Surveys(**args), SurveyPages(**args), SurveyQuestions(**args), SurveyResponses(**args)] + + @staticmethod + def get_authenticator(config: Mapping[str, Any]): + # backward compatibility + if config.get("access_token"): + token = config.get("access_token") + else: + token = config.get("credentials", {}).get("access_token") + + return TokenAuthenticator(token=token) diff --git a/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/spec.json b/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/spec.json index 08e3f37d8030..529fca524ae2 100644 --- a/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/spec.json +++ b/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/spec.json @@ -2,10 +2,10 @@ "documentationUrl": "https://docs.airbyte.io/integrations/sources/surveymonkey", "connectionSpecification": { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "PostHog Spec", + "title": "SurveyMonkey Spec", "type": "object", - "required": ["start_date", "access_token"], - "additionalProperties": false, + "required": ["start_date"], + "additionalProperties": true, "properties": { "start_date": { "title": "Start Date", @@ -14,11 +14,77 @@ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z?$", "examples": ["2021-01-01T00:00:00Z"] }, - "access_token": { - "type": "string", - "airbyte_secret": true, - "description": "API Token. See the docs for information on how to generate this key." + "credentials": { + "type": "object", + "title": "Authentication Type", + "oneOf": [ + { + "title": "Authenticate via OAuth", + "type": "object", + "required": [ + "client_id", + "client_secret", + "access_token", + "auth_type" + ], + "properties": { + "auth_type": { + "type": "string", + "const": "OAuth", + "enum": ["OAuth"], + "default": "OAuth", + "order": 0 + }, + "client_id": { + "title": "Client ID", + "type": "string", + "description": "The Client ID of your developer application", + "airbyte_secret": true + }, + "client_secret": { + "title": "Client Secret", + "type": "string", + "description": "The client secret of your developer application", + "airbyte_secret": true + }, + "access_token": { + "title": "Access Token", + "type": "string", + "description": "An access token generated using the above client ID and secret", + "airbyte_secret": true + } + } + }, + { + "type": "object", + "title": "Token Authentication", + "additionalProperties": false, + "required": ["access_token", "auth_type"], + "properties": { + "auth_type": { + "type": "string", + "const": "Token", + "enum": ["Token"], + "default": "Token", + "order": 0 + }, + "access_token": { + "type": "string", + "airbyte_secret": true, + "description": "API Token. See the docs for information on how to generate this key." + } + } + } + ] } } + }, + "authSpecification": { + "auth_type": "oauth2.0", + "oauth2Specification": { + "rootObject": ["credentials", 0], + "oauthFlowInitParameters": [["client_id"], ["client_secret"]], + "oauthFlowOutputParameters": [["access_token"]] + } } } diff --git a/docs/integrations/sources/surveymonkey.md b/docs/integrations/sources/surveymonkey.md index 74348b5ef07c..aa8847c9bf18 100644 --- a/docs/integrations/sources/surveymonkey.md +++ b/docs/integrations/sources/surveymonkey.md @@ -55,6 +55,7 @@ Please read this [docs](https://developer.surveymonkey.com/api/v3/#getting-start | Version | Date | Pull Request | Subject | | :--- | :--- | :--- | :--- | +| 0.1.2 | 2021-10-27 | [7433](https://github.com/airbytehq/airbyte/pull/7433) | Add OAuth support | | 0.1.1 | 2021-09-10 | [5983](https://github.com/airbytehq/airbyte/pull/5983) | Fix caching for gzip compressed http response | | 0.1.0 | 2021-07-06 | [4097](https://github.com/airbytehq/airbyte/pull/4097) | Initial Release |