Configure third-party login (optional)

Show GitCode / GitHub / Gitee / Huawei login buttons on the login page; skip this if you only use local accounts.

Grape has two login methods; distinguish them first:

Login method What it is When to use it
Local account Username + password The first administrator is generated by the deployment configuration; you can sign in right after installation
Third-party login OAuth buttons for GitCode / GitHub / Gitee / Huawei accounts Configure when you want team members to sign in with code platform accounts

Login channels refers to the second method. It does not create accounts or assign permissions; it only makes third-party login buttons appear on the login page and lets third-party authorization return to your Grape address.

When configuration is needed

Your situation Configure or not
Only the local administrator account is used No; sign in directly after installation
Team members sign in with GitCode / GitHub / Gitee accounts Configure the corresponding channels
No third-party buttons on the login page, or the buttons are grayed out See this page
Clicking a third-party login returns to localhost or reports a callback error See "Failure states" on this page

Before you start

  1. A Grape address that a browser can reach, for example https://grape.example.com
  2. An OAuth application created on the code platform, with its client_id and client_secret
  3. The callback URL pattern: {Grape address}/api/auth/callback/{platform}

Step 1: Configure the external base address

All OAuth callback URLs are derived from server_base_url. It must be an address the browser can reach, not an internal container address.

  1. Copy the configuration file from the template (the file is not tracked in the repository):
cp configs/server-config.example.json configs/server-config.json
  1. Change server_base_url to your public domain, for example https://grape.example.com

To third-party platforms, localhost and 127.0.0.1 are two different callback addresses. Choose one for local debugging and keep it consistent throughout.

Completion criteria: open /api/health; the returned browser_callback_url and worker_connect_url are the addresses you expect.

When the browser uses the public domain and the Worker uses an internal address, you can configure browser_callback_url and worker_connect_url separately; when they are not configured, they fall back to server_base_url.

Step 2: Create the OAuth application and enter credentials

Create an OAuth application on the code platform

Using GitCode as an example:

  1. Open the OAuth application creation page on GitCode
  2. Enter Grape as the application name
  3. Enter https://<your-domain>/api/auth/callback/gitcode as the callback URL
  4. After creation, copy client_id and client_secret

For GitHub, Gitee, and Huawei, replace the last segment of the callback URL with github, gitee, and huawei respectively.

Enter credentials in the Grape admin console

  1. Sign in with an administrator account
  2. Open Login channels
  3. Find the corresponding platform
  4. Enter client_id and client_secret
  5. Save

Credentials are encrypted and written to the database; do not write them into configs/oauth-providers.json. That file holds only channel definitions (OAuth endpoints, scope, field mapping, brand color). Credentials written there are stripped by the loader, which also emits a warning.

Completion criteria: the admin console shows the channel as saved; the channel card is still there after a restart.

Step 3: Verify the callback URL

The callback URL must match the address registered with the third-party platform byte for byte:

https://<your-domain>/api/auth/callback/gitcode
https://<your-domain>/api/auth/callback/github
https://<your-domain>/api/auth/callback/gitee
https://<your-domain>/api/auth/callback/huawei
  • In development, redirect_uri can be omitted and is derived automatically from server_base_url
  • In production it must be configured explicitly; the startup gate checks it when env=production
  • An extra slash, http instead of https, or an IP address all cause redirect_uri mismatch

Step 4: Verify

  1. Open the console login page
  2. Confirm that the login button for the platform appears
  3. Click the button and complete third-party authorization
  4. Return to the Workbench and confirm that the username is displayed

Local account login still works; third-party login is only an additional entry point.

When you only use local accounts

You can skip all third-party channels:

  • The first administrator account is admin; the password is determined by GRAPE_ADMIN_PASSWORD at deployment time (before the first startup). When it is not set, the default is admin123; change it immediately after the first sign-in
  • Later members are created by an administrator in the admin console
  • Self-service registration is enabled by default; disable or restrict it in the registration policy when needed

This path requires no OAuth application and no third-party callback.

Failure states

Symptom Cause Action
The login page loads normally, but there are no third-party buttons The channel definition is missing, or the credentials were not saved Check whether configs/oauth-providers.json has the corresponding section; re-enter and save in Admin → Login channels
A third-party button is grayed out configured=false for that channel Fill in client_id / client_secret
The callback returns to localhost server_base_url is not configured or is set to a loopback address Change it to a browser-reachable address and restart
The third party reports a redirect_uri mismatch The registered address differs from the derived address Copy the derived address verbatim to the third-party platform
Changes to configs do not take effect in Docker The configuration is a bind mount, but the service was not restarted docker compose restart <service-name>
Production startup reports a security gate With env=production, JWT, email, credential encryption, cookies, and the redirect_uri of each channel are checked Fix each reported item; do not disable production checks
Local account login also fails This is not a login channel problem Check the first administrator password (default admin / admin123, or the GRAPE_ADMIN_PASSWORD set at deployment time), the database, and the startup log; return to Installation and startup methods

Docker deployment | GitHub integration | Account activation and login