How to implement email/password login for Web3Auth with AWS Cognito

Hi team, I’m looking for the way to add email/password login on top of the implementation following the document.
https://web3auth.io/docs/content-hub/guides/cognito
https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/web-no-modal-sdk/custom-authentication/cognito-react-no-modal-example

Could you kindly help providing me the guide or steps that we need to proceed?

Thanks in advance.

@tkt193yk Welcome Aboard!

Your request has been forwarded to our team and we will get back to you with further updates once more information becomes available.

1 Like

You can setup email/password login with AWS Cognito:

Then follow the guide with Web3Auth + AWS Cognito.

1 Like

Thanks, @vjgee!

I would like to ask you to elaborate on client side implementation.

I assume an idToken is issued after a user signs in with Cognito in the way you suggested.
So, what we need to do on our frontend is to pass the idToken as extraLoginOptions instead of using the Cognito domain as follows?

await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
  loginProvider: "jwt",
  extraLoginOptions: {
    id_token: "YOUR_GENERATED_ID_TOKEN",
    verifierIdField: "sub", // sub, email, or custom
  },
});

Yes, that is correct. In the frontend, pass on this id_token to the Web3Auth No Modal SDK to authenticate the user

const web3authProvider = await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
  loginProvider: "jwt",
  extraLoginOptions: {
    id_token: "YOUR_GENERATED_ID_TOKEN",
    domain: "https://YOUR-AWS-COGNITO-DOMAIN",
    verifierIdField: "sub",
  },
 }
);

The major thing to note here is the domain option in the extraLoginOptions object. This is the domain of your AWS Cognito pool so that you can be redirected to login there directly from the Web3Auth Plug and Play No Modal SDK.

1 Like

Great! Thank you for helping me here :grinning:

You are most Welcome :smiley:

Hey, this was very useful. Maybe it is worth including as an alternative option in the main documentation.