Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 Source Google Sheets: Support connecting via oAuth webflow #6354

Merged
merged 9 commits into from
Oct 13, 2021

Conversation

gaart
Copy link
Contributor

@gaart gaart commented Sep 21, 2021

What

Add support for connecting via Ouath webflow

How

Update spec.json schema to support 2 types of authorization
Update google_sheets_source.py, get_credentials method which returns credentials for a specific authorization method
Update helpers.py, add logic for choosing authorization type

Pre-merge Checklist

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions
  • Connector version bumped like described here

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here

@github-actions github-actions bot added the area/connectors Connector related issues label Sep 21, 2021
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Sep 27, 2021
@gaart gaart temporarily deployed to more-secrets September 27, 2021 16:41 Inactive
@CLAassistant
Copy link

CLAassistant commented Sep 27, 2021

CLA assistant check
All committers have signed the CLA.

@gaart gaart temporarily deployed to more-secrets September 28, 2021 10:08 Inactive
@gaart gaart changed the title Source Google Sheets: Support connecting via Oauth webflow 🎉 Source Google Sheets: Support connecting via Oauth webflow Sep 28, 2021
@gaart gaart temporarily deployed to more-secrets September 28, 2021 13:57 Inactive
@gaart
Copy link
Contributor Author

gaart commented Sep 28, 2021

/test connector=connectors/source-google-sheets

🕑 connectors/source-google-sheets https://github.com/airbytehq/airbyte/actions/runs/1282890015
❌ connectors/source-google-sheets https://github.com/airbytehq/airbyte/actions/runs/1282890015
🐛 https://gradle.com/s/6cxjezx66xwta

@jrhizor jrhizor temporarily deployed to more-secrets September 28, 2021 14:00 Inactive
@gaart gaart changed the title 🎉 Source Google Sheets: Support connecting via Oauth webflow 🎉 Source Google Sheets: Support connecting via oAuth webflow Sep 28, 2021
@gaart gaart temporarily deployed to more-secrets October 1, 2021 07:32 Inactive
Copy link
Contributor

@vitaliizazmic vitaliizazmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but requires some improvements.

@@ -4,18 +4,81 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Stripe Source Spec",
"type": "object",
"required": ["spreadsheet_id", "credentials_json"],
"additionalProperties": false,
"required": ["spreadsheet_id"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "credentials" not required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea is to have a backward compatibility with the old-style config, and credentials are still required for auth through the UI

"refresh_token"
],
"properties": {
"auth_type": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, auth_type shouldn't be part of specification. It should be recognized in code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vitaliizazmic this practice is used in the others connectors, could you point to some code with a new approach?

}
}
},
"authSpecification": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on #6456

"client_secret": "invalid_secret",
"refresh_token": "invalid_token"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you format?

@gaart gaart linked an issue Oct 1, 2021 that may be closed by this pull request
@gaart gaart temporarily deployed to more-secrets October 4, 2021 17:30 Inactive
Comment on lines 34 to 37
if credentials.get("auth_type") == "Service":
return service_account.Credentials.from_service_account_info(json.loads(credentials["service_account_info"]), scopes=scopes)
elif credentials.pop("auth_type") == "Client":
return client_account.Credentials.from_authorized_user_info(info=credentials)
Copy link
Contributor

@keu keu Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong, but what will happen here if the first comparison fail?
so the auth_type is already removed, would it always return None?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I read it as a two pops, but nevertheless can't we pop auth_type first and then do if/else logic?

Copy link
Contributor

@keu keu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@gaart
Copy link
Contributor Author

gaart commented Oct 5, 2021

/test connector=connectors/source-google-sheets

🕑 connectors/source-google-sheets https://github.com/airbytehq/airbyte/actions/runs/1309468465
❌ connectors/source-google-sheets https://github.com/airbytehq/airbyte/actions/runs/1309468465
🐛 Binary file (standard input) matches

@jrhizor jrhizor temporarily deployed to more-secrets October 5, 2021 21:43 Inactive
@gaart gaart temporarily deployed to more-secrets October 5, 2021 21:46 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 5, 2021

/test connector=connectors/source-google-sheets

🕑 connectors/source-google-sheets https://github.com/airbytehq/airbyte/actions/runs/1309514388
✅ connectors/source-google-sheets https://github.com/airbytehq/airbyte/actions/runs/1309514388
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        74      8    89%
	 source_acceptance_test/conftest.py                     108    108     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              158    109    31%
	 source_acceptance_test/tests/test_full_refresh.py       18     11    39%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  41     25    39%
	 source_acceptance_test/utils/compare.py                 47     20    57%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py      75     11    85%
	 ------------------------------------------------------------------------
	 TOTAL                                                  778    432    44%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                       Stmts   Miss  Cover
	 --------------------------------------------------------------
	 base_python/__init__.py                       13      0   100%
	 base_python/catalog_helpers.py                10      6    40%
	 base_python/cdk/__init__.py                    0      0   100%
	 base_python/cdk/abstract_source.py            83     59    29%
	 base_python/cdk/streams/__init__.py            0      0   100%
	 base_python/cdk/streams/auth/__init__.py       0      0   100%
	 base_python/cdk/streams/auth/core.py           8      1    88%
	 base_python/cdk/streams/auth/jwt.py            5      5     0%
	 base_python/cdk/streams/auth/oauth.py         37     26    30%
	 base_python/cdk/streams/auth/token.py          9      4    56%
	 base_python/cdk/streams/core.py               63     32    49%
	 base_python/cdk/streams/exceptions.py         10      2    80%
	 base_python/cdk/streams/http.py               67     33    51%
	 base_python/cdk/streams/rate_limiting.py      30     14    53%
	 base_python/cdk/utils/__init__.py              0      0   100%
	 base_python/cdk/utils/casing.py                4      0   100%
	 base_python/client.py                         56     33    41%
	 base_python/entrypoint.py                     70     56    20%
	 base_python/integration.py                    52     25    52%
	 base_python/logger.py                         33     19    42%
	 base_python/schema_helpers.py                 56     41    27%
	 base_python/source.py                         51     34    33%
	 main_dev.py                                    3      3     0%
	 --------------------------------------------------------------
	 TOTAL                                        660    393    40%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                Stmts   Miss  Cover
	 -----------------------------------------------------------------------
	 google_sheets_source/__init__.py                        2      0   100%
	 google_sheets_source/client.py                         22      5    77%
	 google_sheets_source/google_sheets_source.py          102     84    18%
	 google_sheets_source/helpers.py                       128     25    80%
	 google_sheets_source/models/__init__.py                 2      0   100%
	 google_sheets_source/models/spreadsheet.py             34      0   100%
	 google_sheets_source/models/spreadsheet_values.py      12      0   100%
	 main_dev.py                                             6      6     0%
	 -----------------------------------------------------------------------
	 TOTAL                                                 308    120    61%

@jrhizor jrhizor temporarily deployed to more-secrets October 5, 2021 22:02 Inactive
@gaart gaart temporarily deployed to more-secrets October 7, 2021 16:03 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 13, 2021

/test connector=connectors/source-google-sheets

🕑 connectors/source-google-sheets https://github.com/airbytehq/airbyte/actions/runs/1338978299
✅ connectors/source-google-sheets https://github.com/airbytehq/airbyte/actions/runs/1338978299
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        74      8    89%
	 source_acceptance_test/conftest.py                     108    108     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              158    109    31%
	 source_acceptance_test/tests/test_full_refresh.py       18     11    39%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  41     25    39%
	 source_acceptance_test/utils/compare.py                 47     20    57%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py      75     11    85%
	 ------------------------------------------------------------------------
	 TOTAL                                                  778    432    44%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                       Stmts   Miss  Cover
	 --------------------------------------------------------------
	 base_python/__init__.py                       13      0   100%
	 base_python/catalog_helpers.py                10      6    40%
	 base_python/cdk/__init__.py                    0      0   100%
	 base_python/cdk/abstract_source.py            83     59    29%
	 base_python/cdk/streams/__init__.py            0      0   100%
	 base_python/cdk/streams/auth/__init__.py       0      0   100%
	 base_python/cdk/streams/auth/core.py           8      1    88%
	 base_python/cdk/streams/auth/jwt.py            5      5     0%
	 base_python/cdk/streams/auth/oauth.py         37     26    30%
	 base_python/cdk/streams/auth/token.py          9      4    56%
	 base_python/cdk/streams/core.py               63     32    49%
	 base_python/cdk/streams/exceptions.py         10      2    80%
	 base_python/cdk/streams/http.py               67     33    51%
	 base_python/cdk/streams/rate_limiting.py      30     14    53%
	 base_python/cdk/utils/__init__.py              0      0   100%
	 base_python/cdk/utils/casing.py                4      0   100%
	 base_python/client.py                         56     33    41%
	 base_python/entrypoint.py                     70     56    20%
	 base_python/integration.py                    52     25    52%
	 base_python/logger.py                         33     19    42%
	 base_python/schema_helpers.py                 56     41    27%
	 base_python/source.py                         51     34    33%
	 main_dev.py                                    3      3     0%
	 --------------------------------------------------------------
	 TOTAL                                        660    393    40%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                Stmts   Miss  Cover
	 -----------------------------------------------------------------------
	 google_sheets_source/__init__.py                        2      0   100%
	 google_sheets_source/client.py                         22      5    77%
	 google_sheets_source/google_sheets_source.py          102     84    18%
	 google_sheets_source/helpers.py                       129     26    80%
	 google_sheets_source/models/__init__.py                 2      0   100%
	 google_sheets_source/models/spreadsheet.py             34      0   100%
	 google_sheets_source/models/spreadsheet_values.py      12      0   100%
	 main_dev.py                                             6      6     0%
	 -----------------------------------------------------------------------
	 TOTAL                                                 309    121    61%

@jrhizor jrhizor temporarily deployed to more-secrets October 13, 2021 19:36 Inactive
@gaart gaart temporarily deployed to more-secrets October 13, 2021 19:45 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 13, 2021

/publish connector=connectors/source-google-sheets

🕑 connectors/source-google-sheets https://github.com/airbytehq/airbyte/actions/runs/1339023087
✅ connectors/source-google-sheets https://github.com/airbytehq/airbyte/actions/runs/1339023087

@jrhizor jrhizor temporarily deployed to more-secrets October 13, 2021 19:51 Inactive
@gaart gaart merged commit bfe865a into master Oct 13, 2021
@gaart gaart deleted the gaart/6225-google-sheets-ouath-support branch October 13, 2021 20:02
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
…hq#6354)

* Add service account support

* Upd oauth support

* Upd auth creds selector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source Google Sheets: Support connecting via Oauth webflow
6 participants