reflex-google-auth 0.0.3__tar.gz → 0.0.5__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.
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.1
2
+ Name: reflex-google-auth
3
+ Version: 0.0.5
4
+ Summary: Sign in with Google
5
+ Author-email: Masen Furer <m_github@0x26.net>
6
+ License: Apache-2.0
7
+ Project-URL: homepage, https://github.com/masenf/reflex-google-auth
8
+ Keywords: reflex,reflex-custom-components
9
+ Classifier: Development Status :: 4 - Beta
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: reflex>=0.4.6
13
+ Requires-Dist: google-auth[requests]
14
+ Provides-Extra: dev
15
+ Requires-Dist: build; extra == "dev"
16
+ Requires-Dist: twine; extra == "dev"
17
+
18
+ # google-auth
19
+
20
+ Sign in with Google.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install reflex-google-auth
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### Create Google OAuth2 Client ID
31
+
32
+ Head over to https://console.developers.google.com/apis/credentials and sign in with the Google account that should manage the app and credential tokens.
33
+
34
+ - Click "Create Project" and give it a name. After creation the new project should be selected.
35
+ - Click "Configure Consent Screen", Choose "External", then Create.
36
+ - Enter App Name and User Support Email -- these will be shown to users when logging in
37
+ - Scroll all the way down to "Developer contact information" and add your email address, click "Save and Continue"
38
+ - Click "Add or Remove Scopes"
39
+ - Select "Email", "Profile", and "OpenID Connect"
40
+ - Click "Update", then "Save and Continue"
41
+ - Add any test users that should be able to log in during development.
42
+ - From the "Credentials" page, click "+ Create Credentials", then "OAuth client ID"
43
+ - Select Application Type: "Web Application"
44
+ - Add Authorized Javascript Origins: http://localhost, http://localhost:3000, https://example.com (prod domain must be HTTPS)
45
+ - Click "Save"
46
+ - Copy the OAuth "Client ID" and save it for later. Mine looks like 309209880368-4uqd9e44h7t4alhhdqn48pvvr63cc5j5.apps.googleusercontent.com
47
+
48
+ https://github.com/reflex-dev/reflex-examples/assets/1524005/af2499a6-0bda-4d60-b52b-4f51b7322fd5
49
+
50
+ ### Integrate with Reflex app
51
+
52
+ The `GoogleAuthState` provided by this component has a `token_is_valid` var that
53
+ should be checked before returning any protected content.
54
+
55
+ Additionally the `GoogleAuthState.tokeninfo` dict contains the user's profile information.
56
+
57
+ ```python
58
+ from reflex_google_auth import GoogleAuthState, require_google_login
59
+
60
+
61
+ class State(GoogleAuthState):
62
+ @rx.cached_var
63
+ def protected_content(self) -> str:
64
+ if self.token_is_valid:
65
+ return f"This content can only be viewed by a logged in User. Nice to see you {self.tokeninfo['name']}"
66
+ return "Not logged in."
67
+ ```
68
+
69
+ The convenience decorator, `require_google_login`, can wrap an existing component, and
70
+ show the "Sign in with Google" button if the user is not already authenticated. It can be
71
+ used on a page function or any subcomponent function of the page.
72
+
73
+ The "Sign in with Google" button can also be displayed via `google_login()`:
74
+
75
+ ```python
76
+ from reflex_google_auth import google_login, google_oauth_provider
77
+
78
+ def page():
79
+ return rx.div(
80
+ google_oauth_provider(
81
+ google_login(),
82
+ ),
83
+ )
84
+ ```
85
+
86
+ To uniquely identify a user, the `GoogleAuthState.tokeninfo['sub']` field can be used.
87
+
88
+ See the example in
89
+ [masenf/rx_shout](https://github.com/masenf/rx_shout/blob/main/rx_shout/state.py)
90
+ for how to integrate an authenticated Google user with other app-specific user
91
+ data.
@@ -0,0 +1,74 @@
1
+ # google-auth
2
+
3
+ Sign in with Google.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install reflex-google-auth
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Create Google OAuth2 Client ID
14
+
15
+ Head over to https://console.developers.google.com/apis/credentials and sign in with the Google account that should manage the app and credential tokens.
16
+
17
+ - Click "Create Project" and give it a name. After creation the new project should be selected.
18
+ - Click "Configure Consent Screen", Choose "External", then Create.
19
+ - Enter App Name and User Support Email -- these will be shown to users when logging in
20
+ - Scroll all the way down to "Developer contact information" and add your email address, click "Save and Continue"
21
+ - Click "Add or Remove Scopes"
22
+ - Select "Email", "Profile", and "OpenID Connect"
23
+ - Click "Update", then "Save and Continue"
24
+ - Add any test users that should be able to log in during development.
25
+ - From the "Credentials" page, click "+ Create Credentials", then "OAuth client ID"
26
+ - Select Application Type: "Web Application"
27
+ - Add Authorized Javascript Origins: http://localhost, http://localhost:3000, https://example.com (prod domain must be HTTPS)
28
+ - Click "Save"
29
+ - Copy the OAuth "Client ID" and save it for later. Mine looks like 309209880368-4uqd9e44h7t4alhhdqn48pvvr63cc5j5.apps.googleusercontent.com
30
+
31
+ https://github.com/reflex-dev/reflex-examples/assets/1524005/af2499a6-0bda-4d60-b52b-4f51b7322fd5
32
+
33
+ ### Integrate with Reflex app
34
+
35
+ The `GoogleAuthState` provided by this component has a `token_is_valid` var that
36
+ should be checked before returning any protected content.
37
+
38
+ Additionally the `GoogleAuthState.tokeninfo` dict contains the user's profile information.
39
+
40
+ ```python
41
+ from reflex_google_auth import GoogleAuthState, require_google_login
42
+
43
+
44
+ class State(GoogleAuthState):
45
+ @rx.cached_var
46
+ def protected_content(self) -> str:
47
+ if self.token_is_valid:
48
+ return f"This content can only be viewed by a logged in User. Nice to see you {self.tokeninfo['name']}"
49
+ return "Not logged in."
50
+ ```
51
+
52
+ The convenience decorator, `require_google_login`, can wrap an existing component, and
53
+ show the "Sign in with Google" button if the user is not already authenticated. It can be
54
+ used on a page function or any subcomponent function of the page.
55
+
56
+ The "Sign in with Google" button can also be displayed via `google_login()`:
57
+
58
+ ```python
59
+ from reflex_google_auth import google_login, google_oauth_provider
60
+
61
+ def page():
62
+ return rx.div(
63
+ google_oauth_provider(
64
+ google_login(),
65
+ ),
66
+ )
67
+ ```
68
+
69
+ To uniquely identify a user, the `GoogleAuthState.tokeninfo['sub']` field can be used.
70
+
71
+ See the example in
72
+ [masenf/rx_shout](https://github.com/masenf/rx_shout/blob/main/rx_shout/state.py)
73
+ for how to integrate an authenticated Google user with other app-specific user
74
+ data.
@@ -22,8 +22,7 @@ class GoogleLogin(rx.Component):
22
22
  library = "@react-oauth/google"
23
23
  tag = "GoogleLogin"
24
24
 
25
- def get_event_triggers(self):
26
- return {"on_success": lambda data: [data]}
25
+ on_success: rx.EventHandler[lambda data: [data]]
27
26
 
28
27
  @classmethod
29
28
  def create(cls, **props) -> "GoogleLogin":
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.1
2
+ Name: reflex-google-auth
3
+ Version: 0.0.5
4
+ Summary: Sign in with Google
5
+ Author-email: Masen Furer <m_github@0x26.net>
6
+ License: Apache-2.0
7
+ Project-URL: homepage, https://github.com/masenf/reflex-google-auth
8
+ Keywords: reflex,reflex-custom-components
9
+ Classifier: Development Status :: 4 - Beta
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: reflex>=0.4.6
13
+ Requires-Dist: google-auth[requests]
14
+ Provides-Extra: dev
15
+ Requires-Dist: build; extra == "dev"
16
+ Requires-Dist: twine; extra == "dev"
17
+
18
+ # google-auth
19
+
20
+ Sign in with Google.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install reflex-google-auth
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### Create Google OAuth2 Client ID
31
+
32
+ Head over to https://console.developers.google.com/apis/credentials and sign in with the Google account that should manage the app and credential tokens.
33
+
34
+ - Click "Create Project" and give it a name. After creation the new project should be selected.
35
+ - Click "Configure Consent Screen", Choose "External", then Create.
36
+ - Enter App Name and User Support Email -- these will be shown to users when logging in
37
+ - Scroll all the way down to "Developer contact information" and add your email address, click "Save and Continue"
38
+ - Click "Add or Remove Scopes"
39
+ - Select "Email", "Profile", and "OpenID Connect"
40
+ - Click "Update", then "Save and Continue"
41
+ - Add any test users that should be able to log in during development.
42
+ - From the "Credentials" page, click "+ Create Credentials", then "OAuth client ID"
43
+ - Select Application Type: "Web Application"
44
+ - Add Authorized Javascript Origins: http://localhost, http://localhost:3000, https://example.com (prod domain must be HTTPS)
45
+ - Click "Save"
46
+ - Copy the OAuth "Client ID" and save it for later. Mine looks like 309209880368-4uqd9e44h7t4alhhdqn48pvvr63cc5j5.apps.googleusercontent.com
47
+
48
+ https://github.com/reflex-dev/reflex-examples/assets/1524005/af2499a6-0bda-4d60-b52b-4f51b7322fd5
49
+
50
+ ### Integrate with Reflex app
51
+
52
+ The `GoogleAuthState` provided by this component has a `token_is_valid` var that
53
+ should be checked before returning any protected content.
54
+
55
+ Additionally the `GoogleAuthState.tokeninfo` dict contains the user's profile information.
56
+
57
+ ```python
58
+ from reflex_google_auth import GoogleAuthState, require_google_login
59
+
60
+
61
+ class State(GoogleAuthState):
62
+ @rx.cached_var
63
+ def protected_content(self) -> str:
64
+ if self.token_is_valid:
65
+ return f"This content can only be viewed by a logged in User. Nice to see you {self.tokeninfo['name']}"
66
+ return "Not logged in."
67
+ ```
68
+
69
+ The convenience decorator, `require_google_login`, can wrap an existing component, and
70
+ show the "Sign in with Google" button if the user is not already authenticated. It can be
71
+ used on a page function or any subcomponent function of the page.
72
+
73
+ The "Sign in with Google" button can also be displayed via `google_login()`:
74
+
75
+ ```python
76
+ from reflex_google_auth import google_login, google_oauth_provider
77
+
78
+ def page():
79
+ return rx.div(
80
+ google_oauth_provider(
81
+ google_login(),
82
+ ),
83
+ )
84
+ ```
85
+
86
+ To uniquely identify a user, the `GoogleAuthState.tokeninfo['sub']` field can be used.
87
+
88
+ See the example in
89
+ [masenf/rx_shout](https://github.com/masenf/rx_shout/blob/main/rx_shout/state.py)
90
+ for how to integrate an authenticated Google user with other app-specific user
91
+ data.
@@ -1,4 +1,4 @@
1
- reflex>=0.4.2
1
+ reflex>=0.4.6
2
2
  google-auth[requests]
3
3
 
4
4
  [dev]
@@ -7,18 +7,16 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "reflex-google-auth"
10
- version = "0.0.3"
11
- description = "Reflex custom component google-auth"
10
+ version = "0.0.5"
11
+ description = "Sign in with Google"
12
12
  readme = "README.md"
13
13
  license = { text = "Apache-2.0" }
14
14
  requires-python = ">=3.8"
15
15
  authors = [{ name = "Masen Furer", email = "m_github@0x26.net" }]
16
- keywords = [
17
- "reflex",
18
- "reflex-custom-components"]
16
+ keywords = ["reflex", "reflex-custom-components"]
19
17
 
20
18
  dependencies = [
21
- "reflex>=0.4.2",
19
+ "reflex>=0.4.6",
22
20
  "google-auth[requests]",
23
21
  ]
24
22
 
@@ -27,7 +25,7 @@ classifiers = [
27
25
  ]
28
26
 
29
27
  [project.urls]
30
- Homepage = "https://github.com/martinxu9/reflex-google-auth"
28
+ homepage = "https://github.com/masenf/reflex-google-auth"
31
29
 
32
30
  [project.optional-dependencies]
33
31
  dev = ["build", "twine"]
@@ -1,26 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: reflex-google-auth
3
- Version: 0.0.3
4
- Summary: Reflex custom component google-auth
5
- Author-email: Masen Furer <m_github@0x26.net>
6
- License: Apache-2.0
7
- Project-URL: Homepage, https://github.com/martinxu9/reflex-google-auth
8
- Keywords: reflex,reflex-custom-components
9
- Classifier: Development Status :: 4 - Beta
10
- Requires-Python: >=3.8
11
- Description-Content-Type: text/markdown
12
- Requires-Dist: reflex>=0.4.2
13
- Requires-Dist: google-auth[requests]
14
- Provides-Extra: dev
15
- Requires-Dist: build; extra == "dev"
16
- Requires-Dist: twine; extra == "dev"
17
-
18
- # google-auth
19
-
20
- A Reflex custom component google-auth.
21
-
22
- ## Installation
23
-
24
- ```bash
25
- pip install reflex-google-auth
26
- ```
@@ -1,9 +0,0 @@
1
- # google-auth
2
-
3
- A Reflex custom component google-auth.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pip install reflex-google-auth
9
- ```
@@ -1,26 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: reflex-google-auth
3
- Version: 0.0.3
4
- Summary: Reflex custom component google-auth
5
- Author-email: Masen Furer <m_github@0x26.net>
6
- License: Apache-2.0
7
- Project-URL: Homepage, https://github.com/martinxu9/reflex-google-auth
8
- Keywords: reflex,reflex-custom-components
9
- Classifier: Development Status :: 4 - Beta
10
- Requires-Python: >=3.8
11
- Description-Content-Type: text/markdown
12
- Requires-Dist: reflex>=0.4.2
13
- Requires-Dist: google-auth[requests]
14
- Provides-Extra: dev
15
- Requires-Dist: build; extra == "dev"
16
- Requires-Dist: twine; extra == "dev"
17
-
18
- # google-auth
19
-
20
- A Reflex custom component google-auth.
21
-
22
- ## Installation
23
-
24
- ```bash
25
- pip install reflex-google-auth
26
- ```