跳转到内容
POST AI agent ready /v1/totp/validate

TOTP 验证 API - 免费 2FA 代码验证器

检查 TOTP 代码对于给定的共享密钥是否有效。 支持可配置的时间窗口来解决客户端和服务器之间的时钟偏差。

Parameters

stringrequired

The TOTP code to validate.

stringrequired

The Base32-encoded shared secret.

number

Time step in seconds.

number

Number of periods before and after the current one to accept (for clock skew).

Code examples

curl -X POST https://api.botoi.com/v1/totp/validate \
  -H "Content-Type: application/json" \
  -d '{"code":"482937","secret":"JBSWY3DPEHPK3PXP","period":30,"window":1}'

When to use this API

登录2FA验证

用户在登录期间输入其 TOTP 代码后,在授予访问权限之前,根据其存储的机密在服务器端进行验证。

自动化安全测试

在集成测试中生成并验证 TOTP 代码,以验证您的 2FA 中间件拒绝过期或不正确的代码。

Frequently asked questions

漂移值是什么意思?
漂移表示代码匹配的时间步偏移。 0表示当前周期,-1表示上一周期,1表示下一周期。
我应该使用什么窗口值?
窗口 1(默认值)允许来自前一个和下一个 30 秒窗口的代码,这说明了典型的时钟偏差。 增加到 2 以进行宽松的验证。
过期的code还能通过验证吗?
只有时间窗口内的代码才能通过。 窗口 1 接受 30 秒内的代码。 早于此的代码将被拒绝。
是否包含重放保护?
不会。API 执行无状态验证。 为了防止重放攻击,请跟踪服务器上使用的代码并拒绝重复的代码。

Get your API key

Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.