One-Time Token

Generate and verify one-time session tokens.

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.one_time_token
  ]
)

Usage

server.rb
generated = auth.api.generate_one_time_token(
  headers: { "cookie" => request.env["HTTP_COOKIE"] }
)

result = auth.api.verify_one_time_token(
  body: { token: generated[:token] }
)

Routes

MethodPathRuby API method
GET/one-time-token/generateauth.api.generate_one_time_token
POST/one-time-token/verifyauth.api.verify_one_time_token

Options

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

  • disable_client_request
  • disable_set_session_cookie
  • set_ott_header_on_new_session
  • generate_token
  • expires_in
  • store_token

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