reflex-google-auth 0.0.2__py3-none-any.whl → 0.0.3__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  from .decorator import require_google_login
2
- from .google_auth import set_client_id, google_login, google_oauth_provider
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", 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
 
@@ -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
- from . import google_auth
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
- google_auth.CLIENT_ID,
38
+ self.client_id,
27
39
  )
28
40
  except Exception as exc:
29
41
  if self.id_token_json:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reflex-google-auth
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: Reflex custom component google-auth
5
5
  Author-email: Masen Furer <m_github@0x26.net>
6
6
  License: Apache-2.0
@@ -0,0 +1,8 @@
1
+ reflex_google_auth/__init__.py,sha256=StBRDVUPCsMwOVRRgvb_WdzoDkSZoq2RLOoe-YsBExE,291
2
+ reflex_google_auth/decorator.py,sha256=70gaOYTupWTE1m0hd2D8TvcoP0CUNVxtBdezurzXtMM,594
3
+ reflex_google_auth/google_auth.py,sha256=kEWamhRigtOd9BVsLzkrHosm6MTZy8lrlLTLmwVFQwM,826
4
+ reflex_google_auth/state.py,sha256=q3C-tb4z4wfKCbRLsJ6JJuVy1MrTGptYnobo1jyKmuU,1486
5
+ reflex_google_auth-0.0.3.dist-info/METADATA,sha256=b7OIxf9gl62lzfV0oh3eC6P3fGlxz6UiPJlHAvCENoM,671
6
+ reflex_google_auth-0.0.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
7
+ reflex_google_auth-0.0.3.dist-info/top_level.txt,sha256=JB7Letu_7VOfOx5EhyGn_bElQjzSq43-LHafE90wqyM,19
8
+ reflex_google_auth-0.0.3.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- reflex_google_auth/__init__.py,sha256=vvVUS8mmM3hRNW5T4oDfV6kVXYQGYzPh1tcb-kbc_GI,291
2
- reflex_google_auth/decorator.py,sha256=70gaOYTupWTE1m0hd2D8TvcoP0CUNVxtBdezurzXtMM,594
3
- reflex_google_auth/google_auth.py,sha256=EcVF4-Ch2wQKgHcHLmGzEjdt5TEr_BzSsCtroMsO75E,995
4
- reflex_google_auth/state.py,sha256=COkMySf7EIDXnZk8G1ZZ2EWy7bm9SVS9iQeRUf84Gjs,1267
5
- reflex_google_auth-0.0.2.dist-info/METADATA,sha256=V7zxxCjTbbEzEzmvm7Un6_S6abLGO4GRCPEPqeW7bYI,671
6
- reflex_google_auth-0.0.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
7
- reflex_google_auth-0.0.2.dist-info/top_level.txt,sha256=JB7Letu_7VOfOx5EhyGn_bElQjzSq43-LHafE90wqyM,19
8
- reflex_google_auth-0.0.2.dist-info/RECORD,,