Skip to main content

Google Social Login with Web3Auth

Create a Google app

  1. Follow Google’s instructions to set up an OAuth 2.0 app.

  2. Paste the following URI as a redirect URI into the "Authorized redirect URIs" field.

    Google OAuth2.0 App Dashboard

  3. Obtain the OAuth Client ID from your App on the Google Developer dashboard

Set up Google

  1. Create a verifier for your Google application by first clicking on Social Login Provider and then selecting Google as the Login provider from the dropdown list.

    Login Providers list on Web3Auth Dashboard

  2. Paste the Client ID from the Google App(above) to the Client ID field and click on Create.

    Google Client ID on Web3Auth Dashboard

    note

    Google Client ID is the OAuth Client ID obtained from the Google Developer dashboard and it's a required field.

Example

import { OpenloginAdapter } from "@web3auth/openlogin-adapter";

// Create OpenloginAdapter instance once you have created Web3Auth instance
const openloginAdapter = new OpenloginAdapter({
adapterSettings: {
loginConfig: {
// Google login
google: {
verifier: "w3a-google-demo", // Pass the Verifier name here
typeOfLogin: "google", // Pass on the login provider of the verifier you've created
clientId: "519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com", // Pass on the Google `Client ID` here
},
},
},
});

// Configure the adapter with Web3Auth
web3authInstance.configureAdapter(openloginAdapter);

// Initialize Modal
await web3authInstance.initModal();

// Login with Google
await web3authInstance.connect();