Custom JWT Returns [Realm.App - error] App: log_in_with_credentials failed: 401 message: unauthorized

Hi there! Im new in realms, i’ve watch several videos and read the docs, but im still experiencing an error thats not letting me move on and thats the logInWithJWT.

I’ve tested several functionalities with realms transaction as anonymous user and everything works great! But the problem comes when signin in with a custom jwt.

I log in the user with in by own backend returning a jwt.

JWT Sign in BackEnd:

const token = jwt.sign(
      { userId: credentials.userId, email: email },
      process.env.JWT_SECRET,
      {
        algorithm: 'HS256',
        expiresIn: '1d',
      },
    );

Is recieved by res.jwt

  const auth = useAuth();

  const handleLogin = async () => {
    Keyboard.dismiss();
    const res = await dispatch(loginCredentials(login)).unwrap();
    if (res?.success) {
      auth.logInWithJWT(res.jwt);
    }
  };

And the error experienced is this: [Realm.App - error] App: log_in_with_credentials failed: 401 message: unauthorized

With no further detail, console log only shows “{}”

In App Services => Authentication, CustomJWT is enabled and configured with:
Algorith: HS256 (Same as the signing in my BE)
Signing key: Same as process.env.JWT_SECRET in my BE

Regarding metadata i’ve tried

  • Empty
  • Paths: userId & email w/ field names user.id & user.email