SMS based authentication issue AppwriteException: Missing required parameter: "secret"
- 0
- React Native
- Auth

Hi, I am creating sms based login. I am able to send SMS code to my real number however I am receving this error. I can log the "secret" and i can see it is not missing but appwrite is complaining for it. Here is my code.
// 1) Send OTP (creates user automatically if phone is new)
const result= await account.createPhoneToken( ID.unique(), phone);
console.log("SMS based login userid:", result.userId);
return result;
}
async function verifySMS(userId, code) {
// Completes the phone login with the OTP
const secret = String(code).trim();
console.log("SMS secret:", secret);
if (!secret) throw new Error('Code is empty');
// Preferred method for phone OTP:
if (typeof account.updatePhoneSession === 'function') {
await account.updatePhoneSession({ userId, secret });
} else if (typeof account.createSession === 'function') {
// Fallback for older SDKs that still accept token session here
await account.createSession({ userId, secret });
} else {
throw new Error('No suitable session method found in this SDK build');
}
}```
My console log is able to print the "secret" but still getting the error. Here is the console log.
``` LOG SMS based login userid: 68b9efa2001babcdc63
LOG SMS secret: 254643
WARN [AppwriteException: Missing required parameter: "secret"]``` I tried with the Mock number and real number.

As you can see in the logs. The verifySMS() function is receiving userId and code and then it is injecting these required parameters into account.updatePhoneSession() method. Not sure why it is still complaining about " Missing required parameter: "secrete""

Issue is resolved. Thanks here is the correct version of code, in case someone needs it. ``` async function loginSMS(phone) {
const result= await account.createPhoneToken( ID.unique(), phone);
return result;
}
async function verifySMS(userId, code) {
const secret = String(code).trim();
if (!secret) throw new Error('Code is empty');
if (typeof account.updatePhoneSession === 'function') { await account.updatePhoneSession( userId, secret ); } else if (typeof account.createSession === 'function') {
await account.createSession( userId, secret );
} else {
throw new Error('No suitable session method found in this SDK build');
}
}```
Recommended threads
- 401 Unauthorized
Im new to appwrite got an issue , i implemented Oauth but in browser console it says (user role guests missing scopes account... )
- CORS Issue | DID NOT FIND ANYTHING ON DO...
Hello There, I get the Error ```Access to fetch at 'https://fra.cloud.appwrite.io/v1/account' from origin 'http://localhost:5173' has been blocked by CORS poli...
- Realtime didn't work in react native exp...
``` useEffect(() => { const { client } = createClient(); const unsubscribe = client.subscribe(`databases.${process.env.EXPO_PUBLIC_APPWRITE_DATABASE}.t...
