Wraps Stytch's authenticate Session endpoint and validates that the session issued to the user is still valid. The SDK will invoke this method automatically in the background. You probably won't need to call this method directly. It's recommended to use session.getSync and session.onChange instead.
Authenticate session
Method parameters
session_duration_minutes int
Response fields
request_id string
status_code int
session_jwt string
session_token string
member_session object
member object
organization object
import React, { useEffect } from 'react';
import { useStytchB2BClient } from '@stytch/react-native/b2b';
export const AuthenticateSession = () => {
const stytch = useStytchB2BClient();
useEffect(() => {
const authenticate = () => {
if (stytch.session.getSync()) {
stytch.session.authenticate({
session_duration_minutes: 60,
});
}
};
// Refresh session every 50 minutes
let interval = setInterval(authenticate, 3000000);
return () => clearInterval(interval);
}, [stytch]);
return <></>;
};
RESPONSE
200
{
"status_code": 200,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"member_session": {...},
"session_token": "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
"session_jwt": "",
"member": {...},
"organization": {...}
}