Skip to content

Commit

Permalink
fixes types, uses parse_native_representation, removes access_token f…
Browse files Browse the repository at this point in the history
…rom constructor since this is obtained by the class
  • Loading branch information
willi-mueller committed May 25, 2024
1 parent 1655987 commit b4cb6d0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions dlt/sources/helpers/rest_client/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ def __init__(
access_token_request_data: Dict[str, Any],
client_id: TSecretStrValue,
client_secret: TSecretStrValue,
access_token: TSecretStrValue = None,
default_token_expiration: int = 3600,
) -> None:
super().__init__(access_token)
super().__init__()
self.access_token_request_data = access_token_request_data
self.access_token_url = access_token_url
self.client_id = client_id
Expand All @@ -179,7 +178,7 @@ def obtain_token(self) -> None:
response = requests.post(**self.build_access_token_request())
response.raise_for_status()
response_json = response.json()
self.access_token = self.parse_access_token(response_json)
self.parse_native_representation(self.parse_access_token(response_json))
expires_in_seconds = self.parse_expiration_in_seconds(response_json)
self.token_expiry = pendulum.now().add(seconds=expires_in_seconds)

Expand All @@ -190,7 +189,7 @@ def build_access_token_request(self) -> Dict[str, Any]:
def parse_expiration_in_seconds(self, response_json: Any) -> int:
return int(response_json.get("expires_in", self.default_token_expiration))

def parse_access_token(self, response_json: Any) -> TSecretStrValue:
def parse_access_token(self, response_json: Any) -> str:
return str(response_json.get("access_token"))


Expand Down

0 comments on commit b4cb6d0

Please sign in to comment.