I would like to enable signing in with Google OAuth using FastHTML but can't get it working. I'm looking for minimal sample app that shows how to do it.
1 Answer
You will need to incorporate OAuth 2.0 authentication in order to deploy Google Sign-In using FastHTML (or more correctly, FastAPI with HTML templates). Since FastAPI lacks built-in OAuth support, you should usually handle this by using libraries like Authlib or python-social-auth. Here's a how-to manual to get you going:
Establish Google API Passwords:
Go to https://console.developers.google.com/ to access the Google Developer Console. Choose an already-existing project or start a new one. Make OAuth 2.0 Client IDs by navigating to "Credentials". Set up the consent screen and include the relevant URIs for redirects. Install Any Libraries That Are Needed:
copy code in bash pip install fastapi uvicorn authlib aiohttp Build an Application for FastAPI:
Python Take a copy of the fastapi code. import Request, Dependencies, and FastAPI from fastapi.responses HTMLResponse is imported from fastapi.importing OAuth from authlib.integrations.starlette_client import Jinja2Templates for templating
-
I think maybe this is generated from an LLM and possibly truncated? Commented Sep 16 at 19:43