Skip to content

Commit

Permalink
fix: Oauth2 in GSheets
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Mar 26, 2024
1 parent af57ef2 commit 29254c4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Changelog
Next
====

- Fix OAuth2 flow in GSheets (#???)

Version 1.2.17 - 2024-02-23
===========================

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ githubapi =
python-jsonpath>=0.10.3
gsheetsapi =
google-auth>=1.23.0
pyopenssl>=24.0.0
holidaysmemory =
holidays>=0.23
htmltableapi =
Expand Down
7 changes: 5 additions & 2 deletions src/shillelagh/adapters/api/gsheets/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,11 @@ def _run_query(self, sql: str) -> QueryResults:
if response.encoding is None:
response.encoding = "utf-8"

if response.status_code != 200:
raise ProgrammingError(response.text)
try:
response.raise_for_status()
except Exception as ex:
self._check_permissions(ex)
raise ProgrammingError(response.text) from ex

if response.text.startswith(JSON_PAYLOAD_PREFIX):
result = json.loads(response.text[len(JSON_PAYLOAD_PREFIX) :])
Expand Down
5 changes: 5 additions & 0 deletions tests/adapters/api/gsheets/adapter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,11 @@ def test_api_bugs(mocker: MockerFixture) -> None:
status_code=400,
headers={},
)
adapter.register_uri(
"GET",
"https://sheets.googleapis.com/v4/spreadsheets/3/developerMetadata/0",
status_code=200,
)

connection = connect(":memory:", ["gsheetsapi"])
cursor = connection.cursor()
Expand Down

0 comments on commit 29254c4

Please sign in to comment.