Skip to content
Back

otp login invalid token

  • 1
  • Self Hosted
  • Auth
  • Web
husamnas
26 Oct, 2024, 12:40

Hi guys, want to ask why when try create session for opt I pass userId and secret but still give me : Payload example:

{ "userId": "671cdc7dc67c67739e23", "secret": "582862" }

response: { message: 'Invalid token passed in the request.', code: 401, type: 'user_invalid_token', version: '1.6.0' }

My api code in next route :

.post("/verifyOtp", async (c) => { const { userId, secret } = await c.req.json(); try { const { account } = await createAdminClient(); const res = await account.createSession(userId, secret); console.log("res", res);

TypeScript
} catch (error) {
  console.log("error", error);
  return c.json({ success: false, error: error }, 400);
}

})

TL;DR
Developers are facing an issue where creating a session for OTP login with userId and secret is resulting in an 'Invalid token' error. The provided code shows a route that catches the userId and secret from the request and attempts to create a session, but the error persists. Possible solutions include checking if the JWT token is being generated correctly and ensuring proper encoding/decoding of tokens.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more