Home > Software engineering >  How to send Firebase paswordless login link?
How to send Firebase paswordless login link?

Time:06-26

I am trying to implement magic link login to my app. I enabled email login option through Firebase console and localhost is already under the authorized domains. I have the code snippet and the screenshot in the below.

I can see that some request is being done with 200 success code but I receive no email.The code does not throw any error and I have no idea what is wrong at this point. Can someone help?

export const sendMagicLink = (email: string, redirectUrl: string) => {
const auth = getAuth(getClientApp());
const actionCodeSettings = {
    url: redirectUrl,
    handleCodeInApp: true
};
return sendSignInLinkToEmail(auth, email, actionCodeSettings);};
const handleSubmit: svelte.JSX.EventHandler<SubmitEvent, HTMLFormElement> = async ({
        currentTarget
    }) => {
        email = new FormData(currentTarget).get('email') as string;
        const redirectUrl = `${window.location.origin}/auth/confirm`;
        state = 'submitting';

        try {
            await sendMagicLink(email, redirectUrl);
            setMagicEmail(email);
            state = 'success';
        } catch (error) {
            if (error instanceof Error) {
                state = error;
            } else {
                console.log(error);
                state = new Error('something went wrong sending the magic link            
  • Related