I am trying to use passwordless magic links email authentication but bumping into a problem with it.
When I click the magiclink in the email, an error screen which says “Something Went Wrong - The link must be opened on the same device and browser from which you submitted your email address.” shows. And in its HTML source, I found likely-errorcode which says ‘data-event-id=“passwordless-no-session”’.
Actually, I opened the link on the same device and browser from which I submitted my email address on my web app, so I can’t understand why this error happens.
Does any one have any idea about how to fix it?
My app sends the magic link request as the code below;
export async function sendPasswordlessLink(email, state, redirectUri) {
const res = await fetch(`https://${env.AUTH0_DOMAIN}/passwordless/start`, {
method: "POST",
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
client_id: env.AUTH0_CLIENT_ID,
client_secret: env.AUTH0_CLIENT_SECRET,
connection: 'email',
email,
send: 'link',
authParams: {
scope: 'openid profile email',
state,
response_type: 'code',
redirect_uri: redirectUri
}
})
});
if (res.ok) {
return await res.json();
} else {
console.error(await res.json());
throw new Error('Auth0 API error1');
}
}