The Authenticate Discovery Magic Link method wraps the authenticate discovery magic link API endpoint, which validates the discovery magic link token passed in.
If this method succeeds, the intermediate session token will be persisted on device.
The Authenticate Discovery Magic Link method wraps the authenticate discovery magic link API endpoint, which validates the discovery magic link token passed in.
If this method succeeds, the intermediate session token will be persisted on device.
import React, { useEffect } from 'react';
import { Text } from 'react-native';
import { useStytchB2BClient } from '@stytch/react-native/b2b';
export const DiscoveryAuthenticate = ({ token }) => {
const stytch = useStytchB2BClient();
useEffect(() => {
const authenticate = async () => {
if (token) {
try {
const { intermediate_session_token, email_address, discovered_organizations } =
await stytch.magicLinks.discovery.authenticate({
discovery_magic_links_token: token,
});
console.log({ intermediate_session_token, email_address, discovered_organizations });
} catch (error) {
console.error('Authentication error:', error);
}
}
};
authenticate();
}, [token, stytch]);
return <Text>Loading</Text>;
};
{
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"status_code": 200,
"intermediate_session_token": "SeiGwdj5lKkrEVgcEY3QNJXt6srxS3IK2Nwkar6mXD4=",
"email_address": "sandbox@stytch.com",
"discovered_organizations": [{...}, {...}]
}