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

fix: use query params for all httpx requests #662

Merged
merged 1 commit into from
Jan 24, 2025
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
17 changes: 9 additions & 8 deletions supabase_auth/_async/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ async def sign_in_with_oauth(
params["redirect_to"] = redirect_to
if scopes:
params["scopes"] = scopes
url = await self._get_url_for_provider(
url_with_qs, _ = await self._get_url_for_provider(
f"{self._url}/authorize", provider, params
)
return OAuthResponse(provider=provider, url=url)
return OAuthResponse(provider=provider, url=url_with_qs)

async def link_identity(
self, credentials: SignInWithOAuthCredentials
Expand All @@ -428,9 +428,8 @@ async def link_identity(
if scopes:
params["scopes"] = scopes
params["skip_http_redirect"] = "true"
url = await self._get_url_for_provider(
"user/identities/authorize", provider, params
)
url = "user/identities/authorize"
_, query = await self._get_url_for_provider(url, provider, params)

session = await self.get_session()
if not session:
Expand All @@ -439,6 +438,7 @@ async def link_identity(
response = await self._request(
method="GET",
path=url,
query=query,
jwt=session.access_token,
xform=parse_link_identity_response,
)
Expand Down Expand Up @@ -1109,7 +1109,7 @@ async def _get_url_for_provider(
url: str,
provider: Provider,
params: Dict[str, str],
) -> str:
) -> Tuple[str, Dict[str, str]]:
if self._flow_type == "pkce":
code_verifier = generate_pkce_verifier()
code_challenge = generate_pkce_challenge(code_verifier)
Expand All @@ -1124,7 +1124,7 @@ async def _get_url_for_provider(

params["provider"] = provider
query = urlencode(params)
return f"{url}?{query}"
return f"{url}?{query}", params

def _decode_jwt(self, jwt: str) -> DecodedJWTDict:
"""
Expand All @@ -1138,7 +1138,8 @@ async def exchange_code_for_session(self, params: CodeExchangeParams):
)
response = await self._request(
"POST",
"token?grant_type=pkce",
"token",
query={"grant_type": "pkce"},
body={
"auth_code": params.get("auth_code"),
"code_verifier": code_verifier,
Expand Down
17 changes: 11 additions & 6 deletions supabase_auth/_sync/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,10 @@ def sign_in_with_oauth(
params["redirect_to"] = redirect_to
if scopes:
params["scopes"] = scopes
url = self._get_url_for_provider(f"{self._url}/authorize", provider, params)
return OAuthResponse(provider=provider, url=url)
url_with_qs, _ = self._get_url_for_provider(
f"{self._url}/authorize", provider, params
)
return OAuthResponse(provider=provider, url=url_with_qs)

def link_identity(self, credentials: SignInWithOAuthCredentials) -> OAuthResponse:
provider = credentials.get("provider")
Expand All @@ -424,7 +426,8 @@ def link_identity(self, credentials: SignInWithOAuthCredentials) -> OAuthRespons
if scopes:
params["scopes"] = scopes
params["skip_http_redirect"] = "true"
url = self._get_url_for_provider("user/identities/authorize", provider, params)
url = "user/identities/authorize"
_, query = self._get_url_for_provider(url, provider, params)

session = self.get_session()
if not session:
Expand All @@ -433,6 +436,7 @@ def link_identity(self, credentials: SignInWithOAuthCredentials) -> OAuthRespons
response = self._request(
method="GET",
path=url,
query=query,
jwt=session.access_token,
xform=parse_link_identity_response,
)
Expand Down Expand Up @@ -1101,7 +1105,7 @@ def _get_url_for_provider(
url: str,
provider: Provider,
params: Dict[str, str],
) -> str:
) -> Tuple[str, Dict[str, str]]:
if self._flow_type == "pkce":
code_verifier = generate_pkce_verifier()
code_challenge = generate_pkce_challenge(code_verifier)
Expand All @@ -1114,7 +1118,7 @@ def _get_url_for_provider(

params["provider"] = provider
query = urlencode(params)
return f"{url}?{query}"
return f"{url}?{query}", params

def _decode_jwt(self, jwt: str) -> DecodedJWTDict:
"""
Expand All @@ -1128,7 +1132,8 @@ def exchange_code_for_session(self, params: CodeExchangeParams):
)
response = self._request(
"POST",
"token?grant_type=pkce",
"token",
query={"grant_type": "pkce"},
body={
"auth_code": params.get("auth_code"),
"code_verifier": code_verifier,
Expand Down
Loading