# CrushOIDC with Google

This sets up "Sign in with Google" on the login page, with [CrushOIDC](Plugin-CrushOIDC.md): for the accounts of your Google Workspace, or for any Google account.

## 1. Make the credentials at Google

In the Google Cloud console, **APIs & Services** › **Credentials**, in a project of yours:

1. If the project has no consent screen yet, Google asks you to set one up first: the name people will see, and whether it is for your organisation only (**Internal**) or for any Google account (**External**).
2. **Create credentials** › **OAuth client ID**.

| Field | Give |
|---|---|
| **Application type** | **Web application** |
| **Authorized JavaScript origins** | the address of the server without anything after it: `https://files.example.com`. No slash at the end. |
| **Authorized redirect URIs** | the same, ending in `/SSO_OIDC/`: `https://files.example.com/SSO_OIDC/` |

Google shows the **Client ID** and the **Client secret**.

To get people's names and pictures as well as their addresses, turn on the **People API** under **APIs & Services** › **Library**.

## 2. Set the plugin

| Setting | Value |
|---|---|
| **OpenID Configuration URL** | `https://accounts.google.com/.well-known/openid-configuration`. Then **Fetch Configuration**. |
| **Client ID**, **Client Secret** | from Google |
| **Scope** | `openid profile email` |
| **Claim as Username** | `email` |
| **Reject logins if email is unverified** | on |
| **Username matching** | `*@example.com`: see below |
| **PKCE?**, **Verify ID Token?** | on |
| **Login button text** | "Sign in with Google" |

and the settings for [what the user gets](Plugin-CrushOIDC.md#what-the-user-gets).

## Letting in only your people

Google is one provider for the whole world. A registration of the kind **External** lets anybody with a Google account get as far as your server. The server must then say who is welcome:

| With | Lets in |
|---|---|
| **Username matching** `*@example.com` | addresses of your domain |
| **Allowed Email Domains** | the same, by domain |
| **OIDC only used for Authentication** | only people who exist in the User Manager under their address |
| a consent screen of the kind **Internal** | only accounts of your Google Workspace. Google itself refuses all others. This is the best of the four, where it fits. |

Do not rely on roles: Google sends no groups with a sign-in.

## Things to know

- **A consent screen of the kind External that is still "in testing"** lets in only the test users listed at Google, and its tokens end after a week. Publish it when you are done testing.
- **Google asks for consent once** per person, for the scopes you request. Asking for more scopes later asks them again.
- **To reach each person's Google Drive** with their own rights, more scopes and **Get Refresh Token?** are needed: [a VFS from the sign-in](Plugin-CrushOIDC-Custom-VFS.md). Google reviews applications that ask for Drive.

## Not tried for this page

Nothing was run against Google: no account there was used. The steps on the provider's side follow the earlier documentation and the provider's console as it is known; names of menus change over time. The plugin's side is from its screen. Try the first setup with one test user, with **Debug** and **Log HTTP Request Calls** on.
