Start replacing the authenticator
const url = 'https://api.emite.cr/v1/auth/2fa/totp/replace';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"password":"example","code":"123456"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.emite.cr/v1/auth/2fa/totp/replace \ --header 'Content-Type: application/json' \ --data '{ "password": "example", "code": "123456" }'Requires the current password AND a code from the current authenticator, and returns the new one: otpauthUrl, qrCodeDataUrl and manualKey, as in POST /v1/auth/2fa/totp/setup. The current authenticator keeps working until the new one is confirmed at POST /v1/auth/2fa/totp/replace/confirm, within 15 minutes; if that never happens, nothing changes. Starting again replaces the pending one. 409 TWO_FACTOR_NOT_ENABLED without an active authenticator; 400 INVALID_TWO_FACTOR_CODE for a wrong code.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The current password of the account. A wrong one answers 400 INVALID_CURRENT_PASSWORD.
A code from the authenticator being replaced.
Example
123456Responses
Section titled “Responses”The new authenticator, waiting for its first code.
object
The otpauth:// URI an authenticator app reads (RFC 6238 TOTP: SHA-1, 6 digits, 30-second step), labelled with the account email and issued by EmiteCR. It carries the secret: show it only to the person, and never store it.
The same URI as a QR code: a PNG data URL, 256 pixels wide, usable directly as the src of an <img>.
The secret in base32, in groups of four separated by spaces: for typing it into the app when the QR cannot be scanned.
Example
{ "otpauthUrl": "otpauth://totp/EmiteCR:ventas%40emite.cr?secret=JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP&issuer=EmiteCR", "qrCodeDataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA…", "manualKey": "JBSW Y3DP EHPK 3PXP JBSW Y3DP EHPK 3PXP"}