メインコンテンツにスキップ

Add Google as an OAuth provider

This guide explains how to let users sign in to Casdoor with their Google account.


Learning outcomes​

  • Create an OAuth client in Google Cloud.
  • Add Google as an OAuth provider in Casdoor.
  • Read the phone number of users from Google.

What you need​

  • A Google Cloud project. See the Google API Console.
  • Administrator access to the Casdoor admin console

Create an OAuth client in Google Cloud​

  1. Create or select a project.

    New project in Google Cloud

  2. Go to APIs & Services > OAuth consent screen and configure the consent screen.

    OAuth consent screen

    App registration

  3. Go to Credentials, click Create credentials, and select OAuth client ID.

    Credentials page

  4. Select the application type, for example Web application, and add the callback URL of Casdoor, https://<your-casdoor-host>/callback, to Authorized redirect URIs. This is the URL of Casdoor, not of your own application. See Redirect URL and callback URL.

    OAuth client creation form

  5. Create the client and copy the Client ID and the Client secret.

    Client ID and client secret

Add the provider in Casdoor​

  1. In the Casdoor admin console, go to Identity > Providers and add a provider.

  2. Set Category to OAuth and Type to Google.

  3. Enter the Client ID and the Client secret.

    Google provider in Casdoor

  4. Save the provider.

Read the phone number of users​

Google returns the phone number only with an additional scope. You need it, for example, when you turn on Get password.

  1. In Google Cloud, turn on the Google People API.

    Google People API

  2. In Casdoor, add the scope https://www.googleapis.com/auth/user.phonenumbers.read to the provider.

    Scope field of the Google provider

Next steps​

See also​