diff --git a/supabase_auth/_async/gotrue_client.py b/supabase_auth/_async/gotrue_client.py index fc4b0732..feb005f8 100644 --- a/supabase_auth/_async/gotrue_client.py +++ b/supabase_auth/_async/gotrue_client.py @@ -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 @@ -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: @@ -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, ) @@ -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) @@ -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: """ @@ -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, diff --git a/supabase_auth/_sync/gotrue_client.py b/supabase_auth/_sync/gotrue_client.py index 90fa9c88..80d648c5 100644 --- a/supabase_auth/_sync/gotrue_client.py +++ b/supabase_auth/_sync/gotrue_client.py @@ -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") @@ -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: @@ -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, ) @@ -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) @@ -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: """ @@ -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,