Issues with Web3Auth Signup - (Sometimes idToken is undefined,Error: Could not get result from torus nodes)

Please provide the following details too when asking for help in this category:

  • SDK Version: @web3auth/modal@6.1.8
  • Platform: Website (Nextjs)
  • Browser Console Screenshots:


    Just not this, one of the user reported that, he coudn’t sign in first 5 times. And I checked in the backend that the id token was undefined. Then after 10 minutes when he tried again, he was able to sign in.

Could anyone please explain the exact reason, as I need to communicate with my users. Thanks.

Please provide the Web3Auth initialization and login code snippet below:

export const initializeWeb3Auth = async () => {
try {
// console.log(process.env.CLIENT_ID, " client id ashe na?");
const web3auth = new Web3Auth({
clientId: process.env.environment== ENVIRONMENT.PROD? process.env.PROD_CLIENT_ID: process.env.DEV_CLIENT_ID,
chainConfig: {
chainNamespace: “eip155”,
chainId: process.env.environment== ENVIRONMENT.PROD? process.env.PROD_CHAIN_ID: process.env.DEV_CHAIN_ID,
},
web3AuthNetwork: “mainnet”,
});

await web3auth.initModal({
  modalConfig: {
    [WALLET_ADAPTERS.WALLET_CONNECT_V2]: {
      label: "wallet_connect",
      showOnModal: false,
    },
    // Disable Metamask
    [WALLET_ADAPTERS.METAMASK]: {
      label: "metamask",
      showOnModal: false,
    },
    [WALLET_ADAPTERS.TORUS_EVM]: {
      label: "torus",
      showOnModal: false,
    },
    openlogin: {
      label: "openlogin",
      loginMethods: {
        facebook: {
          name: "facebook",
          showOnModal: false,
        },
        reddit: {
          name: "reddit",
          showOnModal: false,
        },
        discord: {
          name: "discord",
          showOnModal: false,
        },
        email_passwordless: {
          name: "email_passwordless",
          showOnModal: false,
        },
        wechat: {
          name: "wechat",
          showOnModal: false,
        },
        weibo: {
          name: "weibo",
          showOnModal: false,
        },
        twitter: {
          name: "twitter",
          showOnModal: false,
        },
        kakao: {
          name: "kakao",
          showOnModal: false,
        },
        line: {
          name: "line",
          showOnModal: false,
        },
        twitch: {
          name: "twitch",
          showOnModal: false,
        },
        apple: {
          name: "apple",
          showOnModal: false,
        },
        github: {
          name: "github",
          showOnModal: false,
        },
        linkedin: {
          name: "linkedin",
          showOnModal: false,
        },
        external_wallet: {
          name: "external_wallet",
          showOnModal: false,
        },
        sms_passwordless: {
          name: "sms_passwordless",
          showOnModal: false,
        },
      },
    },
  },
});
console.log(web3auth.connected, " auto 2 connected");
return web3auth;

} catch (err) {
console.log(err);
}
};

export const connectWeb3Auth = async (dispatch, setWeb3AuthInstance) => {
console.log(“connect call hocche”);
try {
const web3auth = await initializeWeb3Auth()
if (!web3auth.connected) await web3auth.connect();
const user = await web3auth.getUserInfo();

const isEmpty = Object.keys(user).length === 0;
console.log(user, " user", isEmpty);

if (isEmpty) {
  console.log("no user");
  web3auth?.logout();
} else {
  saveConnectedStates(dispatch, web3auth);
  setWeb3AuthInstance(web3auth);
}
console.log("saved web3 states");

} catch (err) {
console.log(“connect error”, err);
}
};

// a different code that that connects with the backend
const user = await web3authInstance.getUserInfo();
console.log(invitation_details.invitation_token);
await backendSignupApi(
dispatch,
props.setStatusCode,
app_pub_key,
user.idToken,
web3authInstance,
invitation_details.invitation_token
);

Can you please share your Dapp URL?

@vjgee

@community2 Thanks for your reply.

I was unable to replicate the issue and able to login successfully without any issue with my Google account and received the confirmation email for the waitlist from your Dapp.

You can look at a similar thread Data ethAddress does not match response address which addresses the problem.

You have been able recreate this as it doesn’t occur all the time. It occurs once in a while for a particular email address. The pattern is undetectable, I feel. If I share the time stamp when the error occurred, would be able to check the logs to detect the root cause?

When the error occurs again, please do share the exact timestamp and logs.

Time stamp - just now - 4:40 PM (GMT+6)
let me know if you need the client id
mail - tahmidislam@iut-dhaka.edu
I could sign in with this email before june. But then since june, this mail gets blocked all the time.


This email tahmidislam@iut-dhaka.edu is a Google account? What version of Chrome does the issue occur on?

yes, it is a google account. It used to work.
My users are facing two kind of problems while signing up -
1.The user who complained the first time, his id token was undefined but after 5-6 failed attempt he was able to login.
2.Another user with an @gmail domain faces the same error this edu email receives

Can you explain how are you getting the IDtoken? Which of our examples are you using for your code? Also, share your package.json file

In the meantime, I have reported this to our Dev team to check.

After 4/5 failed attempts this idToken issue generally is solved automatically.
But the issue with unable to login from share From Auth Network is a persistent one

Frontend

const app_scoped_privkey = await web3authInstance.provider?.request({
        method: "eth_private_key", // use "private_key" for other non-evm chains
      });
      console.log(app_scoped_privkey, " app scoped private key");
      if (typeof app_scoped_privkey === "string") {
const app_pub_key = getPublicCompressed(
          Buffer.from(app_scoped_privkey.padStart(64, "0"), "hex")
        ).toString("hex");

        const user = await web3authInstance.getUserInfo();
        console.log(invitation_details.invitation_token);
        await web3authApi(
          dispatch,
          props.setStatusCode,
          app_pub_key,
          user.idToken,
          web3authInstance,
          invitation_details.invitation_token
        );
}

Backend

 const jwks = jose.createRemoteJWKSet(
    new URL("https://api.openlogin.com/jwks") 
  );
  console.log("check  if idToken is undefined",idToken)
  // Verify the JWT using Web3Auth's JWKS
  const jwtDecoded = await jose.jwtVerify(idToken, jwks, {
    algorithms: ["ES256"],
  });

Your issue has been forwarded to our team to review and we will get back with further updates once available.

Our team reviewed your issue and recommended that since you have only Google login for your Dapp, you should be using PnP Web-Nomodal SDK instead of Modal SDK. You may follow the below guide https://web3auth.io/docs/content-hub/guides/google to help you.