Add Google Login


# Add Google Login

You can add Google login to your applications using Asgardeo and enable users to log in with their Google account.

Follow this guide for instructions.

# Register Asgardeo on Google

You need to register Asgardeo as an OAuth2.0 application on Google.

You can follow the Google documentation (opens new window) for detailed instructions.

  1. Go to the Google Developer console (opens new window), create a new project or select an existing project.

  2. If the APIs & services page isn't already open, do the following:

    1. Open the navigation menu and click View all products. View all products on the Google console

    2. Under Management, click APIs & Services. Select APIs & Services

  3. Go to the Credentials page, click Create Credentials, and select Oauth client ID. Select APIs & Services

  4. Configure your consent screen by clicking Configure Consent Screen and return to Create OAuth client ID screen once you are done.

    For more information, see User Consent (opens new window)

  5. Select the Web application as the application type.

  6. Provide a name for your app and the following URL as the Authorized Redirect URI of the application:

    https://api.asgardeo.io/t/{organization_name}/commonauth
    
    1
  7. Take note of the client ID and client secret generated for the application.

# Register the Google IdP

Now, let's register the Google IdP in Asgardeo.

  1. On the Asgardeo console, go to Develop > Connections.

  2. Click New Connections and select Google.

  3. Enter the following details of the Google identity provider and click Finish:

    Add Google IDP in Asgardeo
    Parameter Description
    Name A unique name for this Google identity provider.
    Client ID The client ID obtained from Google.
    Client secret The client secret obtained from Google.

After the Google identity provider is created, go to the Settings tab and see the list of scopes to which Google has granted permissions.

  • email: Allows to view the user's email address.
  • openid: Allows authentication using OpenID Connect and to obtain the ID token.
  • profile: Allows to view the user's basic profile data.

Asgardeo needs these scopes to get user information. Asgardeo checks the attribute configurations of the application and sends the relevant attributes received from Google to the app. You can read the Google documentation (opens new window) to learn more.

# Enable Google login

Before you begin

You need to have an application registered in Asgardeo. If you don't already have one, register one of the following application types:

  1. On the Asgardeo console, go to Develop > Applications.

  2. Open your application from the list and go to the Sign-in Method tab.

  3. If you haven't already defined a sign-in flow, click Start with Default configuration to get started.

  4. Click Add Authentication on the step, select your Google identity provider, and click Add.

    Add Google login in Asgardeo

# Try it out

Follow the steps given below.

  1. Access the application URL.

  2. Click Login to open the Asgardeo login page.

  3. On the Asgardeo login page, Sign in with Google.

    Login with Google
  4. Log in to Google with an existing user account.

When a user successfully logs in with Google for the first time, a user account is created in the Asgardeo console with the Google username. This new user account will be managed by Google.