From 837441b48a0e7fafff32893541c18dd2c70ad202 Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Sat, 15 Jan 2022 07:54:29 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- gotrue/_async/api.py | 12 +++++------- gotrue/_sync/api.py | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/gotrue/_async/api.py b/gotrue/_async/api.py index b9f7afa1..ed01cb53 100644 --- a/gotrue/_async/api.py +++ b/gotrue/_async/api.py @@ -31,7 +31,7 @@ def __init__( self.url = url self.headers = headers self.cookie_options = cookie_options - self.http_client = http_client if http_client else AsyncClient() + self.http_client = http_client or AsyncClient() async def __aenter__(self) -> AsyncGoTrueAPI: return self @@ -238,10 +238,9 @@ async def sign_in_with_phone( error : APIError If an error occurs """ - headers = self.headers - query_string = "?grant_type=password" data = {"phone": phone, "password": password} - url = f"{self.url}/token{query_string}" + url = f'{self.url}/token?grant_type=password' + headers = self.headers response = await self.http_client.post(url, json=data, headers=headers) return Session.parse_response(response) @@ -575,10 +574,9 @@ async def refresh_access_token(self, *, refresh_token: str) -> Session: error : APIError If an error occurs """ - headers = self.headers - query_string = "?grant_type=refresh_token" data = {"refresh_token": refresh_token} - url = f"{self.url}/token{query_string}" + url = f'{self.url}/token?grant_type=refresh_token' + headers = self.headers response = await self.http_client.post(url, json=data, headers=headers) return Session.parse_response(response) diff --git a/gotrue/_sync/api.py b/gotrue/_sync/api.py index f024687d..36b3852c 100644 --- a/gotrue/_sync/api.py +++ b/gotrue/_sync/api.py @@ -31,7 +31,7 @@ def __init__( self.url = url self.headers = headers self.cookie_options = cookie_options - self.http_client = http_client if http_client else SyncClient() + self.http_client = http_client or SyncClient() def __enter__(self) -> SyncGoTrueAPI: return self @@ -238,10 +238,9 @@ def sign_in_with_phone( error : APIError If an error occurs """ - headers = self.headers - query_string = "?grant_type=password" data = {"phone": phone, "password": password} - url = f"{self.url}/token{query_string}" + url = f'{self.url}/token?grant_type=password' + headers = self.headers response = self.http_client.post(url, json=data, headers=headers) return Session.parse_response(response) @@ -575,10 +574,9 @@ def refresh_access_token(self, *, refresh_token: str) -> Session: error : APIError If an error occurs """ - headers = self.headers - query_string = "?grant_type=refresh_token" data = {"refresh_token": refresh_token} - url = f"{self.url}/token{query_string}" + url = f'{self.url}/token?grant_type=refresh_token' + headers = self.headers response = self.http_client.post(url, json=data, headers=headers) return Session.parse_response(response)