OAuth Proxy

Proxy OAuth callbacks through a stable URL.

This page documents the current Ruby port behavior. Ruby uses snake_case option names and auth.api method names; HTTP paths and JSON keys keep the upstream wire shape where implemented.

Configure

config/auth.rb
require "better_auth"

auth = BetterAuth.auth(
  secret: ENV.fetch("BETTER_AUTH_SECRET"),
  base_url: ENV.fetch("BETTER_AUTH_URL", "http://localhost:3000"),
  plugins: [
    BetterAuth::Plugins.oauth_proxy(current_url: ENV.fetch("BETTER_AUTH_URL"), production_url: ENV.fetch("BETTER_AUTH_PRODUCTION_URL"))
  ]
)

Usage

server.rb
status, headers, body = auth.api.o_auth_proxy(
  query: {
    callbackURL: "/dashboard",
    cookies: params[:cookies]
  },
  as_response: true
)

Routes

MethodPathRuby API method
GET/oauth-proxy-callbackauth.api.o_auth_proxy

Options

Current Ruby options accepted by BetterAuth::Plugins.oauth_proxy:

  • max_age
  • current_url
  • production_url

Support Notes

  • The examples above are based on Ruby plugin source and tests in packages/better_auth.
  • If an upstream section is not represented here, treat it as not yet documented or not yet supported by the Ruby port until the matching Ruby implementation exists.

On this page