Reflex custom component google-auth
Project description
Google-Auth
A Reflex custom component Google Auth.
Usage
Please go to this blog post for how to use the component in a Reflex App.
Below is a short code example that goes to Google for authentication and redirects upon success. It still needs code to handle/store the tokens, etc.
from rxconfig import config
import reflex as rx
from rx_google_auth import google_auth, google_login
from google.auth.transport import requests
from google.oauth2.id_token import verify_oauth2_token
CLIENT_ID = "YOUR_CLIENT_ID"
class State(rx.State):
"""The app state."""
def on_success(self, id_token: dict):
print(
verify_oauth2_token(
id_token["credential"],
requests.Request(),
CLIENT_ID,
)
)
def index() -> rx.Component:
return rx.center(
rx.theme_panel(),
rx.vstack(
rx.heading("Welcome to Reflex!", size="9"),
rx.text("Test your custom component by editing ", rx.code(filename)),
google_auth(
google_login(
on_success=State.on_success,
),
client_id=CLIENT_ID,
),
align="center",
spacing="7",
font_size="2em",
),
height="100vh",
)
# Add state and page to the app.
app = rx.App()
app.add_page(index)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for reflex_google_auth-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64b203bcca330567b1277765094d72d01e9c75d982bfeab65019642fbc5f88d5 |
|
MD5 | 3def61d797237b70837fe125ad866e28 |
|
BLAKE2b-256 | 16c4dd5ed85b5c2b0db0e55816f31eadf163d76daea416a339f17b51dcce3527 |