# Google OAuth Setup
This guide walks through setting up Google OAuth for your Calagopus Panel.

::: warning
Google's login page leaks your email address in the `Developer info` popup, opened by clicking the app name:
![App Name](/docs/additional/setting-up-oauth/files/images/google/warning.webp)

![Developer info](/docs/additional/setting-up-oauth/files/images/google/warning2.webp)

If you don't want your personal email to be shared, you have 2 options:
* **1. Create a separate Google account with a work email.** The work email is shown instead, keeping bot spam away from your personal address.
* **2. Don't use Google OAuth.** Use another provider from [this list](/docs/additional/setting-up-oauth).
:::

### Prerequisites
To set up Google OAuth, you need:
* [A Google account](https://accounts.google.com)
* A running Calagopus Panel

### Downloading required files
Download the `google.yml` template to import the Google provider configuration without entering values manually.

Right-click the link below and save the file locally.

<a href="/oauth2/google.yml" download>Download <code>google.yml</code> ➚</a>

### Import the template config
Once `google.yml` has been downloaded, head to your Calagopus Panel's admin page, and click on `OAuth Providers` on the side.
![OAuth Providers tab](/docs/additional/setting-up-oauth/files/images/oauth-providers.webp)

Then, click on the Import button and import the `google.yml` file.
![Import OAuth Button](/docs/additional/setting-up-oauth/files/images/import.webp)

Once imported, click on the newly created Google provider's ID and you should arrive to a page similar to this:
![Google OAuth page](/docs/additional/setting-up-oauth/files/images/google/page.webp)

Copy the Redirect URL provided by the panel and proceed to the next step.

### Setting up Google OAuth

#### Select or create a Google Cloud project
Go to [Google Cloud console](http://console.cloud.google.com), for example, by clicking Console on [Google Cloud landing page](https://cloud.google.com/).
![](/docs/additional/setting-up-oauth/files/images/google/image-1.webp)

Once there, select a project that you want to use for the Google OAuth app.
![](/docs/additional/setting-up-oauth/files/images/google/image-2.webp)

::: details How to create a project in Google Cloud?
In the `Select a project` pop-up, click `New project`.
![](/docs/additional/setting-up-oauth/files/images/google/image-3.webp)

Pick a name for the project, in this case Calagopus. The organisation field can be left to no organization.
![](/docs/additional/setting-up-oauth/files/images/google/image-4.webp)

Once the project has been created, wait for all the other steps to complete and then select the project.
![](/docs/additional/setting-up-oauth/files/images/google/image-5.webp)
:::

#### Register the OAuth application
In the search bar, search for `APIs & Services`.
![](/docs/additional/setting-up-oauth/files/images/google/image-6.webp)

Then in the left sidebar, pick `OAuth consent screen` to begin the OAuth application registration.
![](/docs/additional/setting-up-oauth/files/images/google/image-7.webp)

Then, on the `Google Auth Platform not configured yet` page, click on the `Get started` button.
![](/docs/additional/setting-up-oauth/files/images/google/image-8.webp)

On the next screen, pick the name of the application to show on the login page and add your contact information. Then, click on `Next`.
![](/docs/additional/setting-up-oauth/files/images/google/image-9.webp)

Choose `External` for the application type and then click `Next`.
![](/docs/additional/setting-up-oauth/files/images/google/image-10.webp)

Add your contact information again, and then click `Next`.
![](/docs/additional/setting-up-oauth/files/images/google/image-11.webp)

Accept the Google API Services: User Data Policy, and then click `Continue`, and then finally `Create`.
![](/docs/additional/setting-up-oauth/files/images/google/image-12.webp)

Go back to the `Branding` tab at the left sidebar, and scroll down until you find `Authorized domains`. Add a new domain, and enter the top private domain your Calagopus Panel is located on. For example, if your panel is `test.example.com`, you would put `example.com`. Finally, click the `Save` button.
![](/docs/additional/setting-up-oauth/files/images/google/image-13.webp)

::: warning
Do NOT fill out the `App logo` field, as this will require getting your app verified, which can take some time.
:::

Next, go to the `Audience` tab, and publish the application.
![](/docs/additional/setting-up-oauth/files/images/google/image-14.webp)

#### Issue an OAuth client and key for that application
Go back to the `APIs & Services` page. To do so, search for `APIs & Services` in the search bar.
![](/docs/additional/setting-up-oauth/files/images/google/image-6.webp)

Pick `Credentials` in the sidebar. Click `+ Create credentials` dropdown and select `OAuth client ID`.
![](/docs/additional/setting-up-oauth/files/images/google/image-15.webp)

Pick `Web application` for the application type, type the name for the client, and add the redirect URL. Then, create the OAuth Client ID by clicking the `Create` button.
![](/docs/additional/setting-up-oauth/files/images/google/image-16.webp)

Copy both your Client ID and your Client secret, and then you can close Google Cloud. You will need those for the next step.
![](/docs/additional/setting-up-oauth/files/images/google/image-17.webp)

### Configuring the OAuth Provider
Back in the panel, enter the Client ID and Client Secret you copied from Google Cloud.

On the switches below, choose if you want to enable Google OAuth, only allow login, allow the user to view the connection and allow the user to link and unlink their accounts.

It should normally look like this:
![Google Config](/docs/additional/setting-up-oauth/files/images/google/page.webp)

Finally, save your changes.

### Test the configuration
To test your configuration, head into your account settings, click on `OAuth Links` at the sidebar, and connect to your Google account.
![Testing Google](/docs/additional/setting-up-oauth/files/images/google/test.webp)

If everything works correctly, you should now be able to see your Google account in your list.
![List](/docs/additional/setting-up-oauth/files/images/google/list.webp)

### Troubleshooting

#### Error: "Redirect URI Mismatch" or "Invalid Redirect URI"
The redirect URL in Google Cloud doesn't match the one provided by Calagopus Panel.

**Solution:**

1. Go back to your Calagopus Panel OAuth provider configuration page
2. Copy the exact Redirect URL shown
3. Go to [Google Cloud Console](https://console.cloud.google.com)
4. Navigate to APIs & Services → Credentials
5. Click on your OAuth 2.0 Client ID
6. Under "Authorized redirect URIs", ensure the URL matches exactly (including `https://`, trailing slashes, etc.)
7. Click `Save`

#### Error: "Invalid Client" or "Unauthorized Client"
The Client ID or Client Secret is incorrect.

**Solution:**

1. Go to [Google Cloud Console](https://console.cloud.google.com)
2. Navigate to APIs & Services → Credentials
3. Click on your OAuth 2.0 Client ID
4. Copy your Client ID
5. Create a new Client Secret by clicking `Add Secret` under "Client secrets"
6. Update both values in your Calagopus Panel OAuth provider configuration
7. Save the changes

#### Error: "Access Blocked: Authorization Error" with message about app not being verified
**Cause:** Your Google OAuth app is in testing mode or not published.

**Solution:**

1. Go to [Google Cloud Console](https://console.cloud.google.com)
2. Navigate to APIs & Services → OAuth consent screen
3. Go to the `Audience` tab
4. Click `Publish App` button
5. Confirm the publishing action

#### Error: "Invalid Domain" or domain-related errors
**Cause:** Your panel's domain is not added to the authorized domains list.

**Solution:**

1. Go to [Google Cloud Console](https://console.cloud.google.com)
2. Navigate to APIs & Services → OAuth consent screen
3. Go to the `Branding` tab
4. Scroll to "Authorized domains"
5. Add your top-level domain (e.g., `example.com` if your panel is at `panel.example.com`)
6. Click `Save`
