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 stored in the browser as a cookie.
Authenticate discovery magic link
Method parameters
discovery_magic_links_token* string
import React, { useEffect } from 'react';
import { useStytchB2BClient } from '@stytch/react/b2b';
export const DiscoveryAuthenticate = () => {
const stytch = useStytchB2BClient();
const authenticate = async () => {
const token = new URLSearchParams(window.location.search).get('token');
if (token) {
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 });
}
};
useEffect(() => {
authenticate();
});
return <div>Loading</div>;
};
RESPONSE
200
{
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"status_code": 200,
"intermediate_session_token": "SeiGwdj5lKkrEVgcEY3QNJXt6srxS3IK2Nwkar6mXD4=",
"email_address": "sandbox@stytch.com",
"discovered_organizations": [{...}, {...}]
}