BA
Better Auth•4d ago
Pander

Manually verifying magic link token throws unexpected invalid_type

In my Expo mobile app, I'm trying to verify the magic link token manually as described here. But when I try to call the verify method with my token, I receive the following error:
{"code": "______CODE_INVALID_TYPE____EXPECTED_STRING____RECEIVED_UNDEFINED____PATH_______TOKEN________MESSAGE_REQUIRED__", "details": [{"code": "invalid_type", "expected": "string", "message": "Required", "path": [Array], "received": "undefined"}], "message": "[
{
\"code\": \"invalid_type\",
\"expected\": \"string\",
\"received\": \"undefined\",
\"path\": [
\"token\"
],
\"message\": \"Required\"
}
]", "status": 400, "statusText": ""}
{"code": "______CODE_INVALID_TYPE____EXPECTED_STRING____RECEIVED_UNDEFINED____PATH_______TOKEN________MESSAGE_REQUIRED__", "details": [{"code": "invalid_type", "expected": "string", "message": "Required", "path": [Array], "received": "undefined"}], "message": "[
{
\"code\": \"invalid_type\",
\"expected\": \"string\",
\"received\": \"undefined\",
\"path\": [
\"token\"
],
\"message\": \"Required\"
}
]", "status": 400, "statusText": ""}
and this is my code setup:
import * as SecureStore from 'expo-secure-store'
import { createAuthClient } from 'better-auth/react'
import { expoClient } from '@better-auth/expo/client'
import { magicLinkClient } from 'better-auth/client/plugins'

export const auth = createAuthClient({
baseURL: process.env.EXPO_PUBLIC_API_URl,
plugins: [magicLinkClient(), expoClient({ storage: SecureStore })],
})

auth.magicLink.verify({ query: { token: 'inserted_valid_token' } }).then((res) => console.log(res.error))
import * as SecureStore from 'expo-secure-store'
import { createAuthClient } from 'better-auth/react'
import { expoClient } from '@better-auth/expo/client'
import { magicLinkClient } from 'better-auth/client/plugins'

export const auth = createAuthClient({
baseURL: process.env.EXPO_PUBLIC_API_URl,
plugins: [magicLinkClient(), expoClient({ storage: SecureStore })],
})

auth.magicLink.verify({ query: { token: 'inserted_valid_token' } }).then((res) => console.log(res.error))
I can verify that we're actually sending a token as string. Anyone has any idea perhaps? Thanks!
Magic link | Better Auth
Magic link plugin
1 Reply
Bart âš¡
Bart ⚡•8h ago
Hey, did you manage to solve it? I'm facing the same issue right now 😦

Did you find this page helpful?