Skip to content

Commit a011543

Browse files
authored
fix issues with reflex 0.7.2 in the google auth blog (#1248)
1 parent 612070c commit a011543

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

blog/2023-10-25-implementing-sign-in-with-google.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ and effectively log the user out of the app.
193193

194194
```python
195195
import json
196+
from typing import Any
196197

197198
class State(rx.State):
198199
id_token_json: str = rx.LocalStorage()
@@ -201,7 +202,7 @@ class State(rx.State):
201202
self.id_token_json = json.dumps(id_token)
202203

203204
@rx.var(cache=True)
204-
def tokeninfo(self) -> dict[str, str]:
205+
def tokeninfo(self) -> dict[str, Any]:
205206
try:
206207
return verify_oauth2_token(
207208
json.loads(self.id_token_json)["credential"],
@@ -347,9 +348,9 @@ def protected() -> rx.Component:
347348

348349
## Putting the Pieces Together
349350

350-
All of the code for this example is available in the
351-
["google_auth"](https://github.com/reflex-dev/reflex-examples/tree/a4ffe6cacf8f38b54b95b72b0d525a91b69da3b3/google_auth)
352-
subdirectory inside the `reflex-examples` repo.
351+
The production code for this example has been published as a reuable third-party
352+
component, [`reflex-google-auth`](https://github.com/masenf/reflex-google-auth)
353+
and can be used directly in any Reflex app.
353354

354355
### react_oauth_google.py
355356

@@ -378,6 +379,7 @@ import functools
378379
import json
379380
import os
380381
import time
382+
from typing import Any
381383

382384
from google.auth.transport import requests
383385
from google.oauth2.id_token import verify_oauth2_token
@@ -396,7 +398,7 @@ class State(rx.State):
396398
self.id_token_json = json.dumps(id_token)
397399

398400
@rx.var(cache=True)
399-
def tokeninfo(self) -> dict[str, str]:
401+
def tokeninfo(self) -> dict[str, Any]:
400402
try:
401403
return verify_oauth2_token(
402404
json.loads(self.id_token_json)["credential"],

0 commit comments

Comments
 (0)