Skip to content
Open
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
6 changes: 5 additions & 1 deletion sdk/python/packages/flet/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ dependencies = [
"flet-cli; extra == 'cli'",
"flet-web; extra == 'web'",
"oauthlib >=3.2.2; platform_system != 'Emscripten'",
"httpx >=0.28.1; platform_system != 'Emscripten'",
"httpx2 >=2.12.0; platform_system != 'Emscripten'",
# Required by the packaged-app bootstrap (templates/build/*/lib/python.dart),
# which imports certifi unconditionally to configure the CA bundle. It used
# to arrive transitively via httpx; httpx2 no longer depends on it.
"certifi >=2024.2.2; platform_system != 'Emscripten'",
"repath >=0.9.0",
"msgpack >=1.1.0",
"typing-extensions; python_version < '3.11'"
Expand Down
24 changes: 12 additions & 12 deletions sdk/python/packages/flet/src/flet/auth/authorization_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ async def request_token(self, code: str):
code: Provider-issued authorization code returned to redirect URL.

Raises:
httpx.HTTPStatusError: If token endpoint returns a non-success status.
httpx2.HTTPStatusError: If token endpoint returns a non-success status.
"""
import httpx
import httpx2
from oauthlib.oauth2 import WebApplicationClient

client = WebApplicationClient(self.provider.client_id)
Expand All @@ -129,10 +129,10 @@ async def request_token(self, code: str):
)
headers = self.__get_default_headers()
headers["content-type"] = "application/x-www-form-urlencoded"
req = httpx.Request(
req = httpx2.Request(
"POST", self.provider.token_endpoint, content=data, headers=headers
)
async with httpx.AsyncClient(follow_redirects=True) as client:
async with httpx2.AsyncClient(follow_redirects=True) as client:
resp = await client.send(req)
resp.raise_for_status()
client = WebApplicationClient(self.provider.client_id)
Expand Down Expand Up @@ -193,7 +193,7 @@ async def __refresh_token(self):
or does not include a refresh token.

Raises:
httpx.HTTPStatusError: If the refresh request fails.
httpx2.HTTPStatusError: If the refresh request fails.
"""

if (
Expand All @@ -204,7 +204,7 @@ async def __refresh_token(self):
):
return None

import httpx
import httpx2
from oauthlib.oauth2 import WebApplicationClient

assert self.__token is not None
Expand All @@ -217,11 +217,11 @@ async def __refresh_token(self):
)
headers = self.__get_default_headers()
headers["content-type"] = "application/x-www-form-urlencoded"
refresh_req = httpx.Request(
refresh_req = httpx2.Request(
"POST", url=self.provider.token_endpoint, content=data, headers=headers
)
if refresh_req:
async with httpx.AsyncClient(follow_redirects=True) as client:
async with httpx2.AsyncClient(follow_redirects=True) as client:
refresh_resp = await client.send(refresh_req)
refresh_resp.raise_for_status()
assert self.__token is not None
Expand All @@ -240,16 +240,16 @@ async def __get_user(self) -> User:
`provider.user_id_fn`.

Raises:
httpx.HTTPStatusError: If user endpoint request fails.
httpx2.HTTPStatusError: If user endpoint request fails.
"""
import httpx
import httpx2

assert self.__token is not None
assert self.provider.user_endpoint is not None
headers = self.__get_default_headers()
headers["Authorization"] = f"Bearer {self.__token.access_token}"
user_req = httpx.Request("GET", self.provider.user_endpoint, headers=headers)
async with httpx.AsyncClient(follow_redirects=True) as client:
user_req = httpx2.Request("GET", self.provider.user_endpoint, headers=headers)
async with httpx2.AsyncClient(follow_redirects=True) as client:
user_resp = await client.send(user_req)
user_resp.raise_for_status()
assert self.provider.user_id_fn is not None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ async def _fetch_groups(self, access_token: str) -> list[Group]:
Returns:
A list of :class:`~flet.auth.Group` mapped from `/user/teams`.
"""
import httpx
import httpx2

async with httpx.AsyncClient(follow_redirects=True) as client:
async with httpx2.AsyncClient(follow_redirects=True) as client:
teams_resp = await client.send(
httpx.Request(
httpx2.Request(
"GET",
"https://api.github.com/user/teams",
headers=self.__get_client_headers(access_token),
Expand Down Expand Up @@ -71,11 +71,11 @@ async def _fetch_user(self, access_token: str) -> Optional[User]:
A :class:`~flet.auth.User` built from `/user`; its `email` is populated
from the primary address in `/user/emails` when available.
"""
import httpx
import httpx2

async with httpx.AsyncClient(follow_redirects=True) as client:
async with httpx2.AsyncClient(follow_redirects=True) as client:
user_resp = await client.send(
httpx.Request(
httpx2.Request(
"GET",
"https://api.github.com/user",
headers=self.__get_client_headers(access_token),
Expand All @@ -85,7 +85,7 @@ async def _fetch_user(self, access_token: str) -> Optional[User]:
uj = json.loads(user_resp.text)

emails_resp = await client.send(
httpx.Request(
httpx2.Request(
"GET",
"https://api.github.com/user/emails",
headers=self.__get_client_headers(access_token),
Expand Down