Skip to content

OAuth Popup ​

Runs social sign-in in a popup window: the client navigates the popup to /oauth-popup/start, and on the OAuth callback the plugin swaps the redirect for a page that posts the session token (or error) back to the opener. Mirrors the TS oauthPopup() plugin.

Enable ​

python
from better_auth import BetterAuth
from better_auth.plugins_ext import BearerPlugin, OAuthPopupPlugin

auth = BetterAuth(
    secret="a-strong-32-character-minimum-secret",
    plugins=[OAuthPopupPlugin(), BearerPlugin()],
)

Options ​

None. The plugin takes no options (same as TS).

Endpoints ​

MethodPath
GET/oauth-popup/start

Notes ​

  • Pair it with Bearer Token so the opener can use the posted token.
  • The completion page's inline script is byte-identical to TS and its sha256 is pinned in the response CSP.
  • Implementation note: state is stored through the verification storage plus a signed CSRF cookie, as for every OAuth sign-in, so the normal /callback/{provider} route consumes it unchanged (also /oauth2/callback/{provider} when Generic OAuth runs with legacy_routes=True); additionalData keys sit at the top level of the state, with internal state keys stripped.

MIT licensed · API-compatible with better-auth