Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Okta Developer 16 min read How-to mediumAdept

Build a Flask App with Okta for Secure OIDC Login and Authorized API Calls

A Flask dashboard app signs users in through Okta with OpenID Connect, using Authlib to run the Authorization Code flow with PKCE (S256) automatically. It then uses the OAuth 2.0 access token to call a separate protected resource server. The walkthrough covers registering the Okta remote app, building login, callback and logout routes (including RP-initiated logout with id_token_hint), and storing tokens in the session. It also adds a custom scope (api:read-users) to the authorization server and validates it on the backend with okta-jwt-verifier to control what the API returns.

Related posts

  • GitHub OAuth in your Python Flask app

    Supabase mediumAdept

    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.

  • Build "Sign in with Your App" using Supabase Auth

    Supabase mediumAdept

    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. It uses the authorization code flow with PKCE, issues JWT access tokens carrying a client_id claim alongside the usual user_id and role, and also provides ID tokens, a UserInfo endpoint, refresh tokens, a JWKS endpoint and discovery documents at /.well-known/oauth-authorization-server and /.well-known/openid-configuration. MCP clients can register themselves through dynamic client registration. Existing login methods, Custom Access Token Hooks and Row Level Security all apply to OAuth tokens, so RLS policies can limit each client to specific data by checking the client_id claim. Granular scopes are planned but not yet available.

  • Managed Better Auth is now an OAuth provider, with MCP support

    Neon mediumAdept

    Neon's Managed Better Auth now supports the OAuth Provider plugin, turning an auth instance into an OAuth 2.1 authorization server that both companion apps and MCP clients can use to sign users in. Neon runs the discovery endpoints, JWKS, token issuance and refresh, and client onboarding via Client ID Metadata Documents or optional dynamic registration. You host the login and consent pages and the resource server, where the new @neon/oauth SDK checks token signature, issuer and audience, with adapters for Express, Hono, Next.js and node:http. OAuth configuration is per branch, and each branch gets its own issuer while sharing signing keys, so preview-branch tokens are rejected by production verifiers that pin the issuer.

  • Password Protection with OAuth2 Proxy

    Render mediumAdept

    Putting oauth2-proxy in front of a Render Private Service adds OAuth-based login (Google, GitHub and a dozen other providers) to an existing web app without touching its code. The proxy runs the OAuth 2.0 flow, verifies the returned token out-of-band with the provider using a client ID and secret, then forwards authenticated requests to the backend service, which must not be publicly reachable. Authorization can be limited to members of a Google Group, GitHub org or GitLab project, or the username can be passed to the backend for its own checks. The tradeoff is running and paying for an extra service and dealing with OAuth configuration. Pomerium and BuzzFeed's sso are alternatives.

  • Securing internal web apps

    Figma mediumAdept

    Figma secures internal web apps by putting each behind an AWS Application Load Balancer that authenticates users through Okta via SAML, using a Cognito User Pool as the bridge. Terraform modules provision the setup. Okta sign-in rules enforce WebAuthn and device trust, and the ALB provides managed patching, desync mitigation, WAF and per-app session timeouts. For fine-grained authorization, Okta group memberships flow through the SAML assertion into Cognito's profile attribute and reach the app in the signed x-amzn-oidc-data JWT. The post gives step-by-step verification guidance (kid/region validation, alg checks, manual expiry, issuer checks) and recommends permission-specific groups assigned via Okta Group Rules instead of team-based checks.

The quest for software engineering knowledge.

Look:
Layout: