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

Add arg to set oauth redirect host #340

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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