**Code Snippet:** try { ** const { data: linkResult, error: linkErr } = await client.auth.admin.generateLink({** type: 'recovery', email: normEmail, options: { redirectTo: undefined }, }); console.log('GenerateLink response:', JSON.stringify(linkResult)); if (linkErr) { console.warn('Admin generateLink failed:', linkErr.message); } else { const actionLink = linkResult?.properties?.action_link as string | undefined; let accessToken: string | null = null; let refreshToken: string | null = null; let recoveryToken: string | null = (linkResult as any)?.email_otp?.token ?? null; let linkType: string | null = null; let authCode: string | null = null; if (actionLink) { try { const url = new URL(actionLink); accessToken = url.searchParams.get('access_token'); refreshToken = url.searchParams.get('refresh_token'); if (!recoveryToken) recoveryToken = url.searchParams.get('token'); linkType = url.searchParams.get('type'); authCode = url.searchParams.get('code'); const host = url.host; console.log('Auth link parsed:', { linkType, hasCode: !!authCode, hasAccess: !!accessToken, hasRefresh: !!refreshToken, hasToken: !!recoveryToken, host }); } catch {} } if (accessToken && refreshToken) { sessionData = { access_token: accessToken, refresh_token: refreshToken, expires_in: 3600, token_type: 'bearer', user: authUser }; } else if (authCode) { const { data: ex, error: exErr } = await publicClient.auth.exchangeCodeForSession(authCode); if (!exErr && ex?.session?.access_token && ex?.session?.refresh_token) { sessionData = { access_token: ex.session.access_token, refresh_token: ex.session.refresh_token, expires_in: (ex.session as any).expires_in ?? 3600, token_type: (ex.session as any).token_type ?? 'bearer', user: ex.user ?? authUser, }; } else if (exErr) { console.warn('exchangeCodeForSession failed:', exErr.message); } } else if (recoveryToken) { const verifyType = (linkType === 'recovery' || linkType === 'magiclink' || linkType === 'invite' || linkType === 'signup') ? (linkType as any) : 'recovery'; const verifyOtpReq: any = { email: normEmail, token: recoveryToken, type: verifyType }; console.log('verifyOtp Request:', JSON.stringify(verifyOtpReq)); ** const { data: verified, error: verifyErr } = await publicClient.auth.verifyOtp(verifyOtpReq);** if (!verifyErr && verified?.session?.access_token && verified?.session?.refresh_token) { sessionData = { access_token: verified.session.access_token, refresh_token: verified.session.refresh_token, expires_in: (verified.session as any).expires_in ?? 3600, token_type: (verified.session as any).token_type ?? 'bearer', user: verified.user ?? authUser, }; } else if (verifyErr) { console.warn('verifyOtp fallback failed:', JSON.stringify(verifyErr)); } } } } catch (e) { console.warn('Session generation error:', (e as any)?.message || e); } **Sample logs:** GenerateLink response: {"properties":{"action_link":"https://xxxxxxxxxxxxxxxxxxxxx.supabase.co/auth/v1/verify?token=6a829addc84dfd84c6a54948b8101978c88c33dfe4282c2eec9dfa87&type=recovery&redirect_to=http://localhost:3000","email_otp":"526577","hashed_token":"6a829addc84dfd84c6a54948b8101978c88c33dfe4282c2eec9dfa87","redirect_to":"http://localhost:3000","verification_type":"recovery"},"user":{"id":"4f6ab3ae-7e1f-4235-a412-281b532ded42","aud":"authenticated","role":"authenticated","email":"sagar.varmaXXX@gmail.com","email_confirmed_at":"2025-09-20T20:32:01.879418Z","phone":"","confirmed_at":"2025-09-20T20:32:01.879418Z","recovery_sent_at":"2025-09-22T13:13:30.74259855Z","last_sign_in_at":"2025-09-22T04:01:39.281005Z","app_metadata":{"provider":"email","providers":["email"]},"user_metadata":{"email":"sagar.varmaXXX@gmail.com","email_verified":true,"phone_verified":false,"sub":"4f6ab3ae-7e1f-4235-a412-281b532ded42"},"identities":[{"identity_id":"66def39d-b03f-44a7-9c18-6c351a4c3b1e","id":"4f6ab3ae-7e1f-4235-a412-XXXXXXXXXXX","user_id":"4f6ab3ae-7e1f-4235-a412-281b532ded42","identity_data":{"email":"sagar.varmaXXX@gmail.com","email_verified":true,"phone_verified":false,"sub":"4f6ab3ae-7e1f-4235-a412-XXXXXXXXXXXXXXXX"},"provider":"email","last_sign_in_at":"2025-09-20T20:26:11.614567Z","created_at":"2025-09-20T20:26:11.614622Z","updated_at":"2025-09-20T20:26:11.614622Z","email":"sagar.varma465@gmail.com"}],"created_at":"2025-09-20T20:26:11.568058Z","updated_at":"2025-09-22T13:13:30.744386Z","is_anonymous":false}} verifyOtp Request payload: {"email":"sagar.varma465@gmail.com","token":"6a829addc84dfd84c6a54948b8101978c88c33dfe4282c2eec9dfa87","type":"recovery"} verifyOtp error response: {"__isAuthError":true,"name":"AuthApiError","status":403,"code":"otp_expired"}