Use one-time codes in API tests

Test a sign-in with two-step codes: keep the authenticator's secret as a variable and let each request make the current code.

In short

A test of a two-step sign-in needs the current six-digit code. Keep the authenticator's secret as a secret variable, and write {{$totp:NAME}} where the code goes: each request makes the code from the secret at that moment.

Steps

  1. Open the API Tester environment and press "Add variable".
  2. Name it, for example otp, paste the authenticator's base32 secret or its otpauth:// address, and tick "Secret".
  3. In the request, write {{$totp:otp}} where the code goes, then send it.

Good to know

Related