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
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
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
| Method | Path | Ruby API method |
|---|---|---|
GET | /one-time-token/generate | auth.api.generate_one_time_token |
POST | /one-time-token/verify | auth.api.verify_one_time_token |
Options
Current Ruby options accepted by BetterAuth::Plugins.one_time_token:
disable_client_requestdisable_set_session_cookieset_ott_header_on_new_sessiongenerate_tokenexpires_instore_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.