reflex-google-auth 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/PKG-INFO +1 -1
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/custom_components/reflex_google_auth/__init__.py +2 -2
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/custom_components/reflex_google_auth/google_auth.py +2 -13
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/custom_components/reflex_google_auth/state.py +14 -2
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/custom_components/reflex_google_auth.egg-info/PKG-INFO +1 -1
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/pyproject.toml +1 -1
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/README.md +0 -0
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/custom_components/reflex_google_auth/decorator.py +0 -0
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/custom_components/reflex_google_auth.egg-info/SOURCES.txt +0 -0
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/custom_components/reflex_google_auth.egg-info/dependency_links.txt +0 -0
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/custom_components/reflex_google_auth.egg-info/requires.txt +0 -0
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/custom_components/reflex_google_auth.egg-info/top_level.txt +0 -0
- {reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
from .decorator import require_google_login
|
2
|
-
from .google_auth import
|
3
|
-
from .state import GoogleAuthState
|
2
|
+
from .google_auth import google_login, google_oauth_provider
|
3
|
+
from .state import GoogleAuthState, set_client_id
|
4
4
|
|
5
5
|
__all__ = [
|
6
6
|
"GoogleAuthState",
|
@@ -1,15 +1,6 @@
|
|
1
|
-
import os
|
2
|
-
|
3
1
|
import reflex as rx
|
4
2
|
|
5
|
-
|
6
|
-
CLIENT_ID = os.environ.get("GOOGLE_CLIENT_ID", "")
|
7
|
-
|
8
|
-
|
9
|
-
def set_client_id(client_id: str):
|
10
|
-
"""Set the client id."""
|
11
|
-
global CLIENT_ID
|
12
|
-
CLIENT_ID = client_id
|
3
|
+
from .state import GoogleAuthState
|
13
4
|
|
14
5
|
|
15
6
|
class GoogleOAuthProvider(rx.Component):
|
@@ -20,7 +11,7 @@ class GoogleOAuthProvider(rx.Component):
|
|
20
11
|
|
21
12
|
@classmethod
|
22
13
|
def create(cls, *children, **props) -> rx.Component:
|
23
|
-
props.setdefault("client_id",
|
14
|
+
props.setdefault("client_id", GoogleAuthState.client_id)
|
24
15
|
return super().create(*children, **props)
|
25
16
|
|
26
17
|
|
@@ -36,8 +27,6 @@ class GoogleLogin(rx.Component):
|
|
36
27
|
|
37
28
|
@classmethod
|
38
29
|
def create(cls, **props) -> "GoogleLogin":
|
39
|
-
from .state import GoogleAuthState
|
40
|
-
|
41
30
|
props.setdefault("on_success", GoogleAuthState.on_success)
|
42
31
|
return super().create(**props)
|
43
32
|
|
{reflex-google-auth-0.0.2 → reflex-google-auth-0.0.3}/custom_components/reflex_google_auth/state.py
RENAMED
@@ -1,6 +1,7 @@
|
|
1
1
|
"""Handle Google Auth."""
|
2
2
|
|
3
3
|
import json
|
4
|
+
import os
|
4
5
|
import time
|
5
6
|
|
6
7
|
from google.auth.transport import requests
|
@@ -8,7 +9,14 @@ from google.oauth2.id_token import verify_oauth2_token
|
|
8
9
|
|
9
10
|
import reflex as rx
|
10
11
|
|
11
|
-
|
12
|
+
|
13
|
+
CLIENT_ID = os.environ.get("GOOGLE_CLIENT_ID", "")
|
14
|
+
|
15
|
+
|
16
|
+
def set_client_id(client_id: str):
|
17
|
+
"""Set the client id."""
|
18
|
+
global CLIENT_ID
|
19
|
+
CLIENT_ID = client_id
|
12
20
|
|
13
21
|
|
14
22
|
class GoogleAuthState(rx.State):
|
@@ -17,13 +25,17 @@ class GoogleAuthState(rx.State):
|
|
17
25
|
def on_success(self, id_token: dict):
|
18
26
|
self.id_token_json = json.dumps(id_token)
|
19
27
|
|
28
|
+
@rx.cached_var
|
29
|
+
def client_id(self) -> str:
|
30
|
+
return CLIENT_ID
|
31
|
+
|
20
32
|
@rx.cached_var
|
21
33
|
def tokeninfo(self) -> dict[str, str]:
|
22
34
|
try:
|
23
35
|
return verify_oauth2_token(
|
24
36
|
json.loads(self.id_token_json)["credential"],
|
25
37
|
requests.Request(),
|
26
|
-
|
38
|
+
self.client_id,
|
27
39
|
)
|
28
40
|
except Exception as exc:
|
29
41
|
if self.id_token_json:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|