1

Obtain Google OAuth Credentials

  • First, obtain the redirect URL from the Hanko console, as you’ll need this for Google configuration. Sign in to the Hanko console and select your project. Navigate to ‘Settings’ in the left sidebar and then to ‘Social connections’. Copy the ‘Redirect URL’. Hanko Callback URL
  • Verify that your allowed redirect URL is configured correctly for your application. Navigate to the ‘URLs’ tab in the left sidebar. Ensure that Allowed redirect URLs includes your App URL + ’**’. Hanko allowed redirect url
  • Navigate to Google Cloud Console, sign in and click on ‘Select a project’ at the top left. Google settings option
  • Select ‘New Project’ from the top right of modal. Google settings option
  • Provide a ‘Project name’, if you want the project to be part of an organization, assign it using the ‘Location’ input and hit ‘Create’ Google settings option
  • Type ‘OAuth’ in the search bar and choose ‘OAuth consent screen’ from the results. Google settings option
  • Configure your Google Auth Platform by clicking ‘Get started’ to begin setup. Google auth configuration
  • Name your app and select a user support Email. Google App Information
  • Select ‘User Type’ depending on your requirements Google Project Audience
  • Navigate to ‘Google Auth Platform’ > ‘Audience’ and publish your app. Google test users
  • Click ‘Clients’ in the left sidebar, then click ‘Create client’. Create oauth client
  • Select ‘Web application’ as the application type. Google settings option
  • Choose a name and paste the Redirect URL (that you obtained from the Hanko console) as an ‘Authorized redirect URI’. Google auth client setup
  • The Google console will display information about the OAuth client. Copy and save both the ‘Client ID’ and ‘Client secret’, as you’ll need these in the next step. Google settings option
2

Configure Google OAuth Credentials with Hanko

  • In the ‘Social connections’ section, select Google and enable its toggle switch.
  • Input the earlier noted ‘Client ID’ and ‘Client Secret’, then click ‘Save’. Hanko Callback URL
3

Implement Google Login in Your Frontend Application

Whether you choose to use the pre-designed UI from the @teamhanko/hanko-elements package or opt for a custom UI with the @teamhanko/hanko-frontend-sdk will determine your approach to frontend integration.
  • Integrate the <hanko-auth> component from hanko-elements based on our frontend guides. If everything is good, the component will display a button for signing in with ‘Google’ in login view.
    Make sure to configure the page the web component is embedded on as your error redirect URL as well as an allowed redirect URL.
    Post successful Google authentication, the backend sets a session cookie and errors during authentication are displayed within the component accordingly.