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. Configure your consent screen, if you haven't done so, by clicking OAuth consent screen.

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

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

  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. Click Create.

  8. 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 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.
Claim syncing for JIT-provisioned users

JIT user provisioning is enabled by default for your external identity provider. If required, you can disable JIT user provisioning.

When a user with a local Asgardeo account uses the same email address to log in through an external identity provider, Asgardeo syncs the claims from the JIT-provisioned user account and the local account.

According to the default behavior of Asgardeo, when JIT user provisioning is enabled, the user claims of the local user account are overridden by the user claims received from the external identity provider.

You can use Asgardeo's identity provider APIs to configure claim syncing between the external identity provider and the local user accounts. This gives you the flexibility to customize the claim syncing behavior according to your specific requirements.

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

Follow the steps below to enable Google as a sign-in method for your application.

Before you begin

You need to register an application with Asgardeo. You can register your own application or use one of the sample applications provided.

  1. On the Asgardeo Console, go to Applications.

  2. Select your application, go to its Login Flow tab and add Google login from your preferred editor:

    Recommendations

    Asgardeo recommends adding your social and enterprise connections to the first authentication step as they are used for identifying the user.

    Using the Classic Editor

    To add Google login using the classic editor:

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

    2. Click Add Authentication on the step, select your Google identity provider, and click Add. Add Google login in Asgardeo

    Using the Visual Editor

    To add Google login using the Visual Editor:

    1. Switch to the Visual Editor tab, by default the Username & Password login flow will be added onto the Visual Editor's workspace.

    2. Click on + Add Sign In Option to add a new authenticator to the same step and select your Google connection. Add Google login in Asgardeo using the Visual Editor

  3. Click Update to save the configurations.

# 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.

# Enable Google One Tap

Google One Tap allows users to login to an application with a single click using their existing Google credentials. Since users can sign in with Google without being taken away from the context of the application, it allows for a more simple and a seamless login experience.

# Configure Google One Tap

You can enable Google One Tap for your application by following the steps below.

  1. On the Google Developer Console,

    1. Follow the above guide to register Asgardeo on Google as a web application.

    2. Select the created web application on the Google Developer Console, and provide the following URL as an authorized JavaScript origin:

      https://accounts.asgardeo.io

      Add authorized JavaScript origins in Google developer console
    3. Click Save to update the changes.

  2. On the Asgardeo Console,

    1. Follow the above guide to Register the Google IdP.

    2. Go to Connections, and select your created Google connection.

    3. Go to its Settings tab and enable Google One Tap.

    4. Click Update to save the changes.

  3. In your application, follow the guide above to enable login with Google.

Google One Tap prompt appears for Chrome and Firefox browsers across Android, iOS, Linux and Windows 10. Safari and Edge users will not see the prompt.

# Try out Google One Tap

Once you configure Google One Tap for your application, access the application from a browser with an existing Google session. Your Asgardeo login page will look as follows. Add Google login in Asgardeo using the Visual Editor

Click Continue as <user> and the user will be logged in to the application with the existing Google session.

# Delete a connection

Before you begin

If your connection has applications associated with it, you will not be able to delete the connection.


Before deleting such connections:
  1. Check the associated applications from the Connected Apps tab of the connection.
  2. Click on an application that uses the connection and you will be redirected to the Sign-in Method tab of the respective application.
  3. Remove the connection from the sign-in flow of the associated applications.
  4. Repeat steps 2 and 3 for all listed applications.
  5. Proceed to delete the connection.

To delete a connection that does not have any applications using it:

  1. On the Asgardeo Console, go to Connections.

  2. Click Set up and navigate to the General tab.

  3. At the bottom of the page, click the button in the Delete connection.

    You cannot delete connections that are available by default.

  4. Select the checkbox and confirm your action.

    Delete connection