Skip to content

User Login with AWS Cognito

In this guide, you will learn how a React/NextJS app integrated with the Arcana Auth SDK can easily onboard users via custom login UI and AWS Cognito as the authentication provider.



Using AWS Cognito to onboard users in a Web3 app that is integrated with the Arcana Auth SDK is simple!

Just a single line of code!

Step 1: Call loginWithSocial function

Make sure that all the prerequisites listed above are met. The app should be successfully registered, configured, and integrated with the Arcana Auth SDK, before adding code to onboard users via AWS Cognito.

await auth.loginWithSocial('aws')

Check if a user is logged in:

const connected = await auth.isLoggedIn()

After onboarding users, developers can add code to access the other Arcana Auth SDK functions in the app. See Arcana Auth SDK Usage Guide for details.

Add code in the application to log out an authenticated user:

await auth.logout()

That is all!

Your app is all set for authenticating users via AWS Cognito. Authenticated users can instantly access the Arcana wallet to sign blockchain transactions.

Apps using Custom IAM Providers

Typically apps integrate with the Arcana Auth SDK for enabling:

  • User onboarding
  • Enabling authenticated users to sign blockchain transactions using the Arcana wallet

Apps use the Arcana Developer Dashboard to configure these features before integrating with the Arcana Auth SDK. For e.g., to enable user onboarding via Google and Discord, the developers must first set up both these social providers using the Arcana Developer Dashboard.

Some apps may choose to not use the Arcana Auth SDK for onboarding users via social providers. Instead, they may use custom IAM providers such as AWS Cognito, for user authentication. These apps too may want to integrate with the Arcana Auth SDK to access the embedded Arcana wallet and allow authenticated users to sign blockchain transactions. The configuration of the Arcana Auth SDK usage will be slightly different for such apps as the custom IAM providers such as AWS Cognito typically aggregate and directly support various authentication verifiers such as Google, Facebook, etc.

Before integrating Arcana Auth SDK with such Web3 apps, the developers need to only configure the custom IAM provider via the Arcana Developer Dashboard. It is not required to configure the authentication verifiers used by the custom IAM providers in the Arcana Developer Dashboard. Simply use the respective custom IAM provider's developer console, e.g., Cognito Developer Console to set up the user authentication verifiers, such as Google, directly and not through the Arcana Developer Dashboard.

No Aggregate Login with Cognito

The aggregate login feature does not work for the custom IAM providers such as Cognito.

If a user has the same email ID registered with say a social provider and with Cognito, logging into an app using Cognito will create a new unique user account even if the user uses the same email as the one used with a social provider or via the passwordless option. What this means is that the wallet address for the same user will be different when Cognito is used to log in and subsequently a social provider or passwordless login is used by the same user having the same email ID.

Arcana JWT Token

Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the Arcana JWT Token. App developers can use this token to verify user login and subsequently generate another token for app use. Learn more about how to verify the Arcana JWT Token for apps deployed on Testnet and Mainnet.

What's Next?

To know more about how to use Web3 wallet operations programmatically in your app, see Arcana wallet Developer's Guide. Refer to the Arcana wallet User's Guide for more information on how authenticated app users can access the wallet UI.

See also

Last update: June 21, 2023 by shaloo