Skip to content

Commit a777b41

Browse files
authored
Add code_verifier and code_challenge to Authorization class (#2810)
1 parent cc57e4a commit a777b41

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

sdk/python/packages/flet-runtime/src/flet_runtime/auth/authorization.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
from flet.version import version
1010
from flet_core.locks import AsyncNopeLock, NopeLock
1111
from flet_core.utils import is_asyncio
12+
from oauthlib.oauth2 import WebApplicationClient
13+
from oauthlib.oauth2.rfc6749.tokens import OAuth2Token
14+
1215
from flet_runtime.auth.oauth_provider import OAuthProvider
1316
from flet_runtime.auth.oauth_token import OAuthToken
1417
from flet_runtime.auth.user import User
15-
from oauthlib.oauth2 import WebApplicationClient
16-
from oauthlib.oauth2.rfc6749.tokens import OAuth2Token
1718

1819

1920
class Authorization:
@@ -76,6 +77,8 @@ def get_authorization_data(self) -> Tuple[str, str]:
7677
self.provider.redirect_url,
7778
scope=self.scope,
7879
state=self.state,
80+
code_challenge=self.provider.code_challenge,
81+
code_challenge_method=self.provider.code_challenge_method,
7982
)
8083
return authorization_url, self.state
8184

@@ -106,6 +109,7 @@ def __get_request_token_request(self, code: str):
106109
redirect_uri=self.provider.redirect_url,
107110
client_secret=self.provider.client_secret,
108111
include_client_id=True,
112+
code_verifier=self.provider.code_verifier,
109113
)
110114
headers = self.__get_default_headers()
111115
headers["content-type"] = "application/x-www-form-urlencoded"

sdk/python/packages/flet-runtime/src/flet_runtime/auth/oauth_provider.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def __init__(
1717
user_endpoint: Optional[str] = None,
1818
user_id_fn: Optional[Callable] = None,
1919
group_scopes: Optional[List[str]] = None,
20+
code_challenge: Optional[str] = None,
21+
code_challenge_method: Optional[str] = None,
22+
code_verifier: Optional[str] = None,
2023
) -> None:
2124
self.client_id = client_id
2225
self.client_secret = client_secret
@@ -28,6 +31,9 @@ def __init__(
2831
self.user_endpoint = user_endpoint
2932
self.user_id_fn = user_id_fn
3033
self.group_scopes = group_scopes if group_scopes is not None else []
34+
self.code_challenge = code_challenge
35+
self.code_challenge_method = code_challenge_method
36+
self.code_verifier = code_verifier
3137

3238
def _name(self):
3339
raise Exception("Not implemented")

0 commit comments

Comments
 (0)