---
title: "GitHub OAuth in your Python Flask app"
description: "Adding GitHub OAuth login to a Flask app with supabase-py comes down to three pieces: a custom FlaskSessionStorage class that extends gotrue's SyncSupportedStorage so the JWT session lives in Flask's session, a per-request Supabase client stored on Flask's g object with flow_type set to PKCE for server-side OAuth handling, and two routes."
url: "https://swe.quest/articles/github-oauth-in-your-python-flask-app-15290baa39728dda"
canonical: "https://supabase.com/blog/oauth2-login-python-flask-apps"
source: "Supabase"
published: "2023-11-21"
difficulty: "medium"
kind: "How-to"
reading_minutes: 3
tags: ["identity-auth","python"]
---

# GitHub OAuth in your Python Flask app

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2023-11-21, 3 min read, How-to. Original: [https://supabase.com/blog/oauth2-login-python-flask-apps](https://supabase.com/blog/oauth2-login-python-flask-apps)

## Summary

Adding GitHub OAuth login to a Flask app with supabase-py comes down to three pieces: a custom FlaskSessionStorage class that extends gotrue's SyncSupportedStorage so the JWT session lives in Flask's session, a per-request Supabase client stored on Flask's g object with flow\_type set to PKCE for server-side OAuth handling, and two routes. The sign-in route calls sign\_in\_with\_oauth with a redirect\_to callback URL, and the callback route exchanges the returned code for a session.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Flask basics
- OAuth 2.0 concepts ([easy posts on Identity & auth](https://swe.quest/tags/identity-auth.md?difficulty=easy))

## Keywords

Supabase, supabase-py, Flask, GitHub OAuth, PKCE, gotrue

## Related posts

- [Getting started with Flutter authentication](https://swe.quest/articles/getting-started-with-flutter-authentication-3f9d7f6366544382.md): Supabase · 2023-07-18 · Medium · 8 min read · Identity & auth, Mobile
  Google sign-in for a Flutter app works by using the google\_sign\_in package to obtain an OIDC ID token and access token.
- [Build "Sign in with Your App" using Supabase Auth](https://swe.quest/articles/build-sign-in-with-your-app-using-supabase-auth-a42222eedce43362.md): Supabase · 2025-12-04 · Medium · 6 min read · Identity & auth, AI agents, PostgreSQL
  Supabase Auth can now act as an OAuth 2.1 and OpenID Connect identity provider, letting a project offer "Sign in with \[Your App\]" to third-party apps, MCP-based AI agents, partner integrations and enterprise SSO.
- [Supabase Auth: SSO, Mobile, and Server-side support](https://swe.quest/articles/supabase-auth-sso-mobile-and-server-side-support-6a2bc9b0f4a5ef26.md): Supabase · 2023-04-13 · Medium · 7 min read · Identity & auth, PostgreSQL, Multi-tenancy, Mobile
  Supabase Auth adds SAML 2.0 single sign-on, a PKCE authorization flow for server-side rendering and mobile apps, and native Sign in with Apple on iOS.
- [Custom OIDC Providers for Supabase Auth](https://swe.quest/articles/custom-oidc-providers-for-supabase-auth-f58ec95541f5b5f1.md): Supabase · 2026-04-08 · Medium · 4 min read · Identity & auth
  Supabase Auth now supports connecting any standards-compliant OpenID Connect identity provider, beyond its 20+ built-in social logins, for cases like regional compliance IdPs, self-hosted GitHub Enterprise or GitLab, and niche SSO systems.
- [Supabase Auth: Identity Linking, Hooks, and HaveIBeenPwned integration](https://swe.quest/articles/supabase-auth-identity-linking-hooks-and-haveibeenpwned-integration-8ed59b21ef27e3e6.md): Supabase · 2023-12-14 · Medium · 5 min read · Identity & auth, PostgreSQL
  Supabase Auth adds four features: manual Identity Linking via linkIdentity()/unlinkIdentity() for OAuth identities, session controls (time-boxed sessions, inactivity timeouts, single session per user on Pro and above), leaked password protection using the HaveIBeenPwned Pwned Passwords API with configurable password requirements, and Auth Hooks.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
