Skip to content

Commit

Permalink
Add arg to set oauth redirect host (#340)
Browse files Browse the repository at this point in the history
Co-authored-by: Will Garside <worgarside@gmail.com>
  • Loading branch information
worgarside-dev and worgarside committed Apr 13, 2023
1 parent 3c2340f commit 3e9d8eb
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions wg_utilities/clients/_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(
log_requests: bool = False,
creds_cache_path: Path | None = None,
scopes: list[str] | None = None,
oauth_login_redirect_host: str = "localhost",
):
"""Initialise the client."""
super().__init__(
Expand All @@ -99,6 +100,7 @@ def __init__(
log_requests=log_requests,
creds_cache_path=creds_cache_path,
scopes=scopes,
oauth_login_redirect_host=oauth_login_redirect_host,
)

def get_items(
Expand Down
2 changes: 2 additions & 0 deletions wg_utilities/clients/google_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ def __init__(
scopes: list[str] | None = None,
log_requests: bool = False,
creds_cache_path: Path | None = None,
oauth_login_redirect_host: str = "localhost",
):
super().__init__(
base_url=self.BASE_URL,
Expand All @@ -610,6 +611,7 @@ def __init__(
scopes=scopes or self.DEFAULT_SCOPE,
log_requests=log_requests,
creds_cache_path=creds_cache_path,
oauth_login_redirect_host=oauth_login_redirect_host,
)

self._primary_calendar: Calendar
Expand Down
2 changes: 2 additions & 0 deletions wg_utilities/clients/google_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ def __init__(
creds_cache_path: Path | None = None,
# pylint: disable=line-too-long
item_metadata_retrieval: ItemMetadataRetrieval = ItemMetadataRetrieval.ON_FIRST_REQUEST,
oauth_login_redirect_host: str = "localhost",
):
super().__init__(
base_url=self.BASE_URL,
Expand All @@ -1484,6 +1485,7 @@ def __init__(
scopes=scopes or self.DEFAULT_SCOPE,
log_requests=log_requests,
creds_cache_path=creds_cache_path,
oauth_login_redirect_host=oauth_login_redirect_host,
)

self._my_drive: Drive
Expand Down
2 changes: 2 additions & 0 deletions wg_utilities/clients/google_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def __init__(
scopes: list[str] | None = None,
log_requests: bool = False,
creds_cache_path: Path | None = None,
oauth_login_redirect_host: str = "localhost",
):
super().__init__(
base_url=self.BASE_URL,
Expand All @@ -209,6 +210,7 @@ def __init__(
scopes=scopes or self.DEFAULT_SCOPES,
log_requests=log_requests,
creds_cache_path=creds_cache_path,
oauth_login_redirect_host=oauth_login_redirect_host,
)

self.data_sources: dict[str, DataSource] = {}
Expand Down
2 changes: 2 additions & 0 deletions wg_utilities/clients/google_photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def __init__(
scopes: list[str] | None = None,
log_requests: bool = False,
creds_cache_path: Path | None = None,
oauth_login_redirect_host: str = "localhost",
):
super().__init__(
base_url=self.BASE_URL,
Expand All @@ -365,6 +366,7 @@ def __init__(
scopes=scopes or self.DEFAULT_SCOPES,
log_requests=log_requests,
creds_cache_path=creds_cache_path,
oauth_login_redirect_host=oauth_login_redirect_host,
)

self._albums: list[Album]
Expand Down
2 changes: 2 additions & 0 deletions wg_utilities/clients/monzo.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ def __init__(
client_secret: str,
log_requests: bool = False,
creds_cache_path: Path | None = None,
oauth_login_redirect_host: str = "localhost",
):
super().__init__(
base_url=self.BASE_URL,
Expand All @@ -444,6 +445,7 @@ def __init__(
client_secret=client_secret,
log_requests=log_requests,
creds_cache_path=creds_cache_path,
oauth_login_redirect_host=oauth_login_redirect_host,
)

self._current_account: Account
Expand Down
5 changes: 4 additions & 1 deletion wg_utilities/clients/oauth_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def __init__(
log_requests: bool = False,
creds_cache_path: Path | None = None,
scopes: list[str] | None = None,
oauth_login_redirect_host: str = "localhost",
):
self._client_id = client_id
self._client_secret = client_secret
Expand All @@ -246,6 +247,7 @@ def __init__(
self.auth_link_base = auth_link_base
self.log_requests = log_requests
self._creds_cache_path = creds_cache_path
self.oauth_login_redirect_host = oauth_login_redirect_host

self.scopes = scopes or []

Expand Down Expand Up @@ -571,7 +573,8 @@ def run_first_time_login(self) -> None:

self.temp_auth_server.start_server()

redirect_uri = f"http://localhost:{self.temp_auth_server.port}/get_auth_code"
# pylint: disable=line-too-long
redirect_uri = f"http://{self.oauth_login_redirect_host}:{self.temp_auth_server.port}/get_auth_code"

auth_link = (
self.auth_link_base
Expand Down
5 changes: 4 additions & 1 deletion wg_utilities/clients/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def __init__(
client_secret: str,
log_requests: bool = False,
creds_cache_path: Path | None = None,
scopes: list[str] | None = None,
oauth_login_redirect_host: str = "localhost",
):
super().__init__(
base_url=self.BASE_URL,
Expand All @@ -185,7 +187,8 @@ def __init__(
client_secret=client_secret,
log_requests=log_requests,
creds_cache_path=creds_cache_path,
scopes=self.ALL_SCOPES,
scopes=scopes or self.ALL_SCOPES,
oauth_login_redirect_host=oauth_login_redirect_host,
)

self._current_user: User
Expand Down
4 changes: 3 additions & 1 deletion wg_utilities/clients/truelayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,11 @@ def __init__(
*,
client_id: str,
client_secret: str,
bank: Bank,
log_requests: bool = False,
creds_cache_path: Path | None = None,
scopes: list[str] | None = None,
oauth_login_redirect_host: str = "localhost",
bank: Bank,
):
super().__init__(
base_url=self.BASE_URL,
Expand All @@ -566,6 +567,7 @@ def __init__(
)
),
scopes=scopes or self.ALL_SCOPES,
oauth_login_redirect_host=oauth_login_redirect_host,
)

self.bank = bank
Expand Down

0 comments on commit 3e9d8eb

Please sign in to comment.