Redirect issue in google login

I am using the MPC Core Kit SDK for Google login but facing a redirect issue. When I click login, it redirects me to select an email and click continue. After that, it redirects and the coreKitStatus shows as INITIALIZED.

i am use nextjs and also i have create a path serviceworker/redirect!!

How can I solve this?

Hey, can you please share few details.

  1. The version of MPC Core Kit you are using.
  2. Which login method you are using for google, loginWithoauth or loginWithJWT, along with code snippet.
  3. If you are using the loginWithOAuth can you share your service worker file as well.

@Ayush I have solve the issue but can you give why geting this error
version : “@web3auth/mpc-core-kit”: " ^2.3.3",

I am use loginWithoauthand use in nextjs!!
how can i solve?


const web3AuthClientId = process.env.NEXT_PUBLIC_WEB3AUTH_CLIENTID as string;

const chainConfig = {
  chainNamespace: CHAIN_NAMESPACES.EIP155,
  chainId: '0x1', // Please use 0x1 for Mainnet
  rpcTarget: 'https://rpc.ankr.com/eth',
  displayName: 'Ethereum Mainnet',
  blockExplorer: 'https://etherscan.io/',
  ticker: 'ETH',
  tickerName: 'Ethereum',
};

let coreKitInstance: Web3AuthMPCCoreKit;
let evmProvider: EthereumSigningProvider;

if (typeof window !== 'undefined') {
  coreKitInstance = new Web3AuthMPCCoreKit({
    web3AuthClientId,
    web3AuthNetwork: WEB3AUTH_NETWORK.MAINNET,
    uxMode: 'redirect',
    setupProviderOnInit: false, // needed to skip the provider setup
    manualSync: true, // This is the recommended approach
  });

  // Setup provider for EVM Chain
  evmProvider = new EthereumSigningProvider({ config: { chainConfig } });
  evmProvider.setupProvider(coreKitInstance);
}

const Welcome = () => {
  const dispatch = useDispatch();
  const [coreKitStatus, setCoreKitStatus] = useState<COREKIT_STATUS>(COREKIT_STATUS.NOT_INITIALIZED);
  console.log('🚀 ~ Welcome ~ coreKitStatus:', coreKitStatus);
  const [loading, setLoading] = useState<boolean>(false);
  const chain = useSelector((state: any) => state.web3Login.chainId);
  const theme = useSelector((state: any) => state.theme.theme);
  const backgroundColor = useSelector((state: any) => state.theme.backgroundColor);
  const isLoading = useSelector((state: any) => state.web3Login.isLoading);
  const color = useSelector((state: any) => state.theme.color);


  useEffect(() => {
    const init = async () => {
      await coreKitInstance.init();
      setCoreKitStatus(coreKitInstance.status);

      // Check coreKit status and handle login state
      if (coreKitInstance.status === COREKIT_STATUS.LOGGED_IN) {
        dispatch(userevmProvider(evmProvider));
        dispatch(UsercoreKitInstance(coreKitInstance));
        fetchUserData();
        dispatch(setFetchbalace(true));
      } else if (coreKitInstance.status === COREKIT_STATUS.INITIALIZED) {
        dispatch(setIsLoading(false));
      } else if (coreKitInstance.status === COREKIT_STATUS.REQUIRED_SHARE) {
        console.log('required more shares, please enter your backup/device factor key');
        dispatch(setIsLoading(false));
      }
    };
    init();
  }, []);

  const login = async () => {
    try {
      if (!coreKitInstance) {
        throw new Error('initiated to login');
      }

      const verifierConfig = {
        subVerifierDetails: {
          typeOfLogin: 'google',
          verifier: 'blok-capital',
          clientId: process.env.NEXT_PUBLIC_GOOGLE_ID,
        },
      } as SubVerifierDetailsParams;

      await coreKitInstance.loginWithOauth(verifierConfig);
      if (coreKitInstance.status === COREKIT_STATUS.LOGGED_IN) {
        await coreKitInstance.commitChanges(); // Needed for new accounts
      }

      setCoreKitStatus(coreKitInstance.status);
    } catch (err) {
      console.log(err);
    }
  };

Also i have try with Firebase configuration that time getting error.

image

How can i solve also give me a solution loginWithoauth method ?

Hey, thanks for sharing the code. I’ll try to reproduce the issue and update you. For second issue are you using loginWithJWT, so it seems like your verifier is not expecting email but you are passing sub.

Can you please share the code for the same, and screenshot of verifier from the dashbaord?

Hey @Ayush , thanks for the reply, but the issue has been resolved.