Skip to main content
import { useState } from 'react';
import { useStytchB2BClient } from '@stytch/react/b2b';

export const DiscoveryPasswordAuthenticate = () => {
  const stytch = useStytchB2BClient();
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');

  const authenticate = async () => {
    const response = await stytch.passwords.discovery.authenticate({
      email_address: email,
      password: password,
    });
    console.log('Authenticated:', response);
  };

  return (
    <form>
      <input
        type="email"
        value={email}
        onChange={(e) => setEmail(e.target.value)}
        placeholder="Email"
      />
      <input
        type="password"
        value={password}
        onChange={(e) => setPassword(e.target.value)}
        placeholder="Password"
      />
      <button onClick={authenticate} type="submit">Sign In</button>
    </form>
  );
};
passwords.discovery.authenticate wraps the Discovery Authenticate Password API endpoint. This endpoint verifies that the email has a password currently set, and that the entered password is correct.

Parameters

password
string
required
The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characters, etc.
email_address
string
required
The email address of the Member.

Response

member_id
string
The unique ID of the Member.
member_session
object
The new Stytch Session.
member
object
The Member object of the signed-in Member.
organization
object
The Organization object of the Organization the Member has signed into.
session_jwt
string
The JWT for the new Stytch Session.
If the project is configured to use HttpOnly cookies, this field will always be an empty string.
session_token
string
The secret token for the new Stytch Session.
If the project is configured to use HttpOnly cookies, this field will always be an empty string.
member_device
object
If Protected Auth is enabled and returned fingerprinting results, this field will contain information about the member’s device attributes.
member_authenticated
boolean
Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
intermediate_session_token
string
The intermediate_session_token that should be passed into a secondary authentication endpoint, such as OTP authenticate, in order to receive a member session. The intermediate_session_token can also be used with discovery endpoints to join a different organization or create a new organization.If the member is fully authenticated, this field will be an empty string.
If the project is configured to use HttpOnly cookies, this field will always be an empty string.
primary_required
object | null
The types of primary authentication required.
mfa_required
object | null
The types of secondary authentication required to join the Organization.
member_device
object
If Protected Auth is enabled and returned fingerprinting results, this field will contain information about the member’s device attributes.
request_id
string
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
status_code
number
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.