oscklmO
Convex Community2y ago
3 replies
oscklm

[ConvexAuth]: ERROR Auth token is not a valid JWT, cannot refetch the token

Hey,

I'm using ConvexAuth in app, and specifically, using the password-code from the convex auth demo repo, i'm able to successfully sign up and verify with my email code.

And also able to login when using the password-code provider and flow signIn

But upon being signed in, i get the following error:

ERROR Auth token is not a valid JWT, cannot refetch the token

convex/auth.ts
import { Password } from '@convex-dev/auth/providers/Password';
import { convexAuth } from '@convex-dev/auth/server';
import { ResendOTPPasswordReset } from '../resend/PasswordReset/ResendOTPPasswordReset';
import { ResendOTP } from '../resend/ResendOTP';

export const { auth, signIn, signOut, store } = convexAuth({
  providers: [
    Password({
      id: 'password-code',
      reset: ResendOTPPasswordReset,
      verify: ResendOTP,
    }),
  ],
  callbacks: {
    async afterUserCreatedOrUpdated(ctx, { userId }) {
      if (!userId) return;
      await ctx.db.patch(userId, {
        role: 'user',
      });
    },
  },
  session: {
    totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
    inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
  },
});

SignInScreen.tsx
export const SignInScreen = () => {
  //...
  const { signIn } = useAuthActions();

  const handleLogin = async (values: SignInFormValues) => {
    try {
      await signIn('password-code', {
        flow: 'signIn',
        email: values.email,
        password: values.password,
      });
      router.back();
    } catch (error) {
      console.log(error);
    }
  };

  //...
};
Was this page helpful?