# Connect Apps to Google

## Set up OAuth client on Google Cloud Platform

To configure Google OAuth client for Authgear, you will need to create an OAuth client on Google Cloud Platform first.

### Create a new project

Create a project on Google Cloud Platform through [console](https://console.cloud.google.com/). If you are adding Authgear to your existing Google Cloud Platform projects, you may skip to the next step to create the OAuth client.

### Create OAuth Consent Screen

After creating a new project, you will need to configure the OAuth consent screen. Press the <img src="https://2638622528-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAjXpMovvVxeIY33s_K%2Fuploads%2Fgit-blob-fce945bf1e80f4e4f6099b7a7225c03c9dae66ee%2FGoogle-hamburger-menu.png?alt=media" alt="" data-size="line"> button on the top-left and go to **APIs & Services** -> **OAuth consent screen** and follow the instruction to create the consent screen.

### Create OAuth client ID

1. Go to <img src="https://2638622528-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAjXpMovvVxeIY33s_K%2Fuploads%2Fgit-blob-fce945bf1e80f4e4f6099b7a7225c03c9dae66ee%2FGoogle-hamburger-menu.png?alt=media" alt="" data-size="line"> -> **APIs & services** -> **Credentials**
2. Click **Create Credentials** -> **OAuth client ID**
3. Choose **Web application** in **Application type** and assign a name as reference. You should *always choose Web application* here regardless of the platform of the app you are creating. It is because this OAuth Client ID is used by your Authgear services, which is a web application in Google’s classification.
4. In **Authorized JavaScript origins**, add your Authgear endpoint, e.g. `https://myproject.authgear.cloud`
5. In **Authorized redirect URIs**, add `https://<YOUR_AUTHGEAR_ENDPOINT>/sso/oauth2/callback/google`. For example, `https://myproject.authgear.cloud/sso/oauth2/callback/google`
6. After creating a client ID, you will see the client ID under the **OAuth 2.0 Client IDs** section of the **Credentials** page.

![OAuth Client ID in the Credentials page](https://2638622528-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAjXpMovvVxeIY33s_K%2Fuploads%2Fgit-blob-f0ef452bc20490712a77e651c3d787a5a4411583%2FGCP_create_client_id.png?alt=media)

{% hint style="info" %}
Redirect URI has the form of `/sso/oauth2/callback/:alias`. The `alias` is used as the identifier of OAuth provider. You can configure the `alias` in Authgear Portal.
{% endhint %}

You can find more details in [official Google Cloud Platform doc](https://support.google.com/cloud/answer/6158849)

## Configure Sign in with Google in Authgear Portal

### Get your OAuth Client details

After creating an OAuth client, click the name of OAuth client to view the details.

![Get your OAuth Client ID and Secret in the details page](https://2638622528-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAjXpMovvVxeIY33s_K%2Fuploads%2Fgit-blob-79cf50a630e199e8d193206a41a400bd3b8ee545%2Fgcp_client_details.png?alt=media)

You will need the values of **Client ID**, **Client secret** to configure Google Sign In.

### Configure in Authgear Portal

1. In the portal, go to **Authentication > Social / Enterprise Login**.
2. Enable **Sign in with Google**.
3. Fill in the **Client ID** and **Client Secret** with the values obtained from the previous step.
4. **Save** the settings.

🎉Done! You have just added Google Sign In to your apps!

Your end-users can now sign in with Google on Authgear pre-built Log In and Sign Up page. Existing end-users can connect their account to Google in the [User Settings](https://docs.authgear.com/customization/built-in-ui/user-settings) page.

!["Sign in with Google" in Log in and Sign up page](https://2638622528-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAjXpMovvVxeIY33s_K%2Fuploads%2Fgit-blob-619ea8bac19f6144bb783e7f8d75fb753242ea60%2Fgoogle_sign_in.png?alt=media)

![Your end-users can connect to their Google account in User Settings page](https://2638622528-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAjXpMovvVxeIY33s_K%2Fuploads%2Fgit-blob-3289f17db4aa260220e3f55f24f704f7f0fefd50%2Fconnect_with_google.png?alt=media)
