Authentication

Authentication

Magic's authentication can enable passwordless Web3 onboarding (no seed phrases) using multiple configurable methods. Each method either creates an account address for the user (non-custodial) or utilizes an existing account address. This is handled completely by Magic with out-of-the-box UI, with no lift from the integrating dApp. Currently the supported authentication methods are:

  • Google One Tap
  • Email one-time passcode
  • Third-party wallets

#Use Cases

  • Allow your users to log in and/or sign up to your dapp using their preferred authentication method and gain access to their public wallet address on the network you are connected to.

#Authentication Methods

#Email One-Time Passcode

If a user chooses to authenticate through their email, they will recieve a unique code to their email that's generated per attempt and be required to enter it to authenticate. OTPs for email provides a simple and effective way to increase security and ensure the safety of user assets.

#Google One-Tap

One-tap login with Google provides effortless authentication for your users that have Google Accounts. Utilizing the 'One Tap' sign-up API, users can easily create a secure, passwordless account with just one tap, all within the context of your app. Magic handles all of the authentication flow with Google with no setup for you dapp required.

Note

User's that sign using the email OTP method and/or Google One-Tap will resolve to the same address as long as their gmail address is a personal account with the ending @gmail.com and is automatically linked. Auto-linking is not supported for custom G Suite/Google Workspace domains (such as test@acme.co).

#Third-Party Wallets

Magic Connect allows users to connect with existing third-party wallets (e.g. MetaMask). When a user is asked for a public address, they can select a supported third-party wallet to use from the Magic Connect login view.

The SDK will remember this choice on the client and all further RPC calls will be forwarded to the selected wallet. This selection can be reset by calling the disconnect() SDK method.

Currently, MetaMask and Coinbase Wallet are shown by default for all Magic Connect apps. Visibility of third-party wallets can be toggled on or off via the Wallet Providers page in the Magic developer dashboard.

If you are looking to bring your own authentication provider, see our enterprise solutions for Magic Wallet Services.

#Usage

Magic offers a utility method connectWithUI which will ask permission from your user's selected authentication method to connect to your dapp. ⁠

Javascript
01import { Magic } from "magic-sdk"
02import Web3 from 'web3';
03
04const magic = new Magic('YOUR_API_KEY', { 
05  network: "goerli",
06});
07
08const web3 = new Web3(magic.rpcProvider);
09
10const accounts = await magic.wallet.connectWithUI();

#Configuration

  • You can configure which authentication methods and/or third party wallets are supported by your dapp in your Dashboard settings.
  • See how to brand this experience with your own logo and colors in the customization section.

#Reference

Did you find what you were looking for?