Skip to content

Commit 7a5507d

Browse files
author
Oleksandr Bazarnov
committed
small code format
1 parent dcdaf9b commit 7a5507d

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,20 @@ def __call__(self, request: requests.PreparedRequest) -> requests.PreparedReques
5454

5555
def get_auth_header(self) -> Mapping[str, Any]:
5656
"""HTTP header to set on the requests"""
57-
token = (
58-
self.access_token
59-
if (
60-
not self.get_token_refresh_endpoint()
61-
or not self.get_refresh_token()
62-
and self.access_token
63-
)
64-
else self.get_access_token()
65-
)
57+
token = self.access_token if self._is_access_token_flow else self.get_access_token()
6658
return {"Authorization": f"Bearer {token}"}
6759

60+
@property
61+
def _is_access_token_flow(self) -> bool:
62+
"""
63+
Determines if the current flow is an `access token` flow, meaning that the `access_token_value`
64+
has been provided directly, without triggering the `refresh_access_token()` flow.
65+
66+
Returns:
67+
bool: True if the flow is an access token flow, False otherwise.
68+
"""
69+
return True if self.access_token and not self.get_token_refresh_endpoint() else False
70+
6871
def get_access_token(self) -> str:
6972
"""Returns the access token"""
7073
if self.token_has_expired():

0 commit comments

Comments
 (0)