Consumer Authentication

/

Mobile SDKs

/

React Native SDK reference

/

Passwords

/

Authenticate

Authenticate

The Authenticate method wraps the Authenticate Password API endpoint. This endpoint verifies that the user has a password currently set, and that the entered password is correct.

There are cases where this endpoint will return a reset_password error even if the password entered is correct. View our API Docs for complete details.

If this method succeeds, the user will be logged in, granted an active session, and the session data will be persisted on device.

You can listen for successful login events anywhere in the codebase with the stytch.session.onChange() method or useStytchSession hook.


Method parameters


email*string

password*string

session_duration_minutes*int

Response fields


request_idstring

status_codeint

user_idstring

sessionobject

session_jwtstring

session_tokenstring

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

export const Login = () => {
  const stytch = useStytch();

  const authenticatePassword = useCallback(() => {
    stytch.passwords.authenticate({
      email: '${exampleEmail}',
      password: 'q8Zs)L0t1Emx_I61',
      session_duration_minutes: 60,
    });
  }, [stytch]);

  return (
    <View>
      <TouchableOpacity onPress={authenticatePassword}>
        <Text>Authenticate Password</Text>
      </TouchableOpacity>
    </View>
  );
};

RESPONSE

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