Adding OAuth to the Authentication Service
The Next Step In Extracting Authentication to a Microservice, I described building a dedicated auth service with JWT-based authentication and RBAC. It worked well for email/password authentication,...

Source: DEV Community
The Next Step In Extracting Authentication to a Microservice, I described building a dedicated auth service with JWT-based authentication and RBAC. It worked well for email/password authentication, but we needed more. Enterprise clients wanted SSO via Keycloak. Consumer users expected Google sign-in. Time to add OAuth 2.0. The Providers Keycloak for enterprise SSO. Self-hosted, open source, speaks OIDC fluently. Clients can connect their existing identity provider and we integrate via Keycloak as an intermediary. Google for consumer sign-in. Reduces friction for users who don't want another password. Two different providers, but the OAuth flow is fundamentally the same. FastAPI Library Options I evaluated four libraries: Authlib The most comprehensive OAuth library for Python. Supports OAuth 1.0, OAuth 2.0, and OIDC. Framework-agnostic with FastAPI integration. Pros: Complete spec implementation, well-documented, handles PKCE and JWT validation. Cons: Large library with features you mi