Consumer Authentication

/

Mobile SDKs

/

React Native SDK reference

/

Time-Based One-Time Passcodes (TOTP)

/

Get Recovery Codes

Get recovery codes

Wraps Stytch's recovery_codes endpoint. Call this method to retrieve the recovery codes for a TOTP instance tied to a user.

You can listen for successful user updates anywhere in the codebase with the stytch.user.onChange() method or useStytchUser() hook.

Note: If a user has enrolled another MFA method, this method will require MFA. See the Multi-factor authentication section for more details.

import React, { useCallback } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { useStytch } from '@stytch/react-native';

export const GetTOTPRecoveryCodes = () => {
  const stytch = useStytch();
  const getTOTPRecoveryCodes = useCallback(() => {
    stytch.totp.recoveryCodes();
  }, [stytch]);

  return (
    <View>
      <TouchableOpacity onPress={getTOTPRecoveryCodes}>
        <Text>Get TOTP Recovery Codes</Text>
      </TouchableOpacity>
    </View>
  );
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "totp_id": "totp-test-41920359-8bbb-4fe8-8fa3-aaa83f35f02c",
  "session": null,
  "session_jwt": "",
  "session_token": "",
  "user": {...},
  "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6"
}