# Configure OAuth Login: Google and GitHub | Creght AI Documentation

> OAuth lets visitors sign in to your Creght site with an existing Google or GitHub account. These users belong to your project Auth system, not to the Creght edi…

[![Creght](https://ugc.talizen.com/_assets/site/2061660904709165056/1780797461299__creght_logo.png)Help Center](/help)

[Changelog](/blogs)

[AI](/docs/ai/quick-create-first-website) [Visual](/docs/get-start)

Getting Started

- [Create Your First Website in 5 Minutes](/docs/ai/quick-create-first-website)
- [AI Website Creation Guide](/docs/ai/ai-create-website-guide)
- [Direct Editing: Update Content Without Credits](/docs/ai/ai-edit-content-guide)
- [Use Pick to Bring a Section from Another Template into Your Site](/docs/ai/pick-element-in-tpl)
- [Prompt Library](/docs/ai/prompt-lib)
- [AI Credits Guide](/docs/ai/ai-credits-guide)
- [Creght Skill](/docs/ai/creght-skill)

Backend

- [Add Login, Bookings, Private Pages, and More to Your Website](/docs/ai/backend-database-guide)
- [Configure OAuth Login: Google and GitHub](/docs/ai/backend-auth-guide)

Site Setting

- [Multilingual Website Setup Guide](/docs/ai/localization)
- [Domain Binding Guide](/docs/ai/custom-domain)
- [Alibaba Cloud Domain Purchase Guide (Beginner Version)](/docs/ai/aliyun-domain-registration-guide)
- [Redirect Setup Guide](/docs/ai/redirects)
- [Missing Pages: Redirect or 404?](/docs/ai/redirect-or-404)
- [Meta Pixel Integration Guide](/docs/ai/facebook-meta-pixel)

Advanced Usage

- [Configure Different Default Languages for Different Domains](/docs/ai/domain-locale-routing)

Backend/

# Configure OAuth Login: Google and GitHub

OAuth lets visitors sign in to your Creght site with an existing Google or GitHub account. These users belong to your project Auth system, not to the Creght editor team, so you can use them for member centers, private pages, bookings, downloads, and customer portals.

This guide explains the setup path: create an OAuth app in Google or GitHub, copy the Client ID, Client Secret, and callback URL into Creght, then ask AI to add the login UI.

## Before You Start

- Use the HTTPS domain that visitors are currently using. This can be a preview domain or your production custom domain.
- Open **Backend / Auth / OAuth Providers** in the Creght editor.
- Have access to Google Cloud Console or GitHub Developer Settings.

## Find the Creght Callback URL

The Creght OAuth callback URL is simply **your current site URL + `/auth/oauth/callback/{provider}`**.

```plain-text
https://your-domain.com/auth/oauth/callback/google
https://your-domain.com/auth/oauth/callback/github
```

Make sure the domain is the one your visitors are actually using. If you are using `https://www.example.com`, do not enter a preview domain. If you are testing on a preview domain, use that preview domain.

**Important:** If you change the site domain later, you must update the OAuth callback URL in Google, GitHub, or any other provider console to the new active domain. Otherwise OAuth login will fail because the callback URL no longer matches.

## Google Login

1. Create or select a Google Cloud project.
2. Configure the OAuth consent screen.
3. Create an OAuth client with application type **Web application**.
4. Add your site origin, for example `https://your-domain.com`.
5. Add `https://your-domain.com/auth/oauth/callback/google` as an authorized redirect URI.
6. Copy the Client ID and Client Secret.

| Creght field | Value |
| --- | --- |
| Provider Key | `google` |
| Display Name | `Google` |
| Redirect URL | `https://your-domain.com/auth/oauth/callback/google` |
| Scopes | `openid,profile,email` |
| Issuer | `https://accounts.google.com` |
| Authorization URL | `https://accounts.google.com/o/oauth2/v2/auth` |
| Token URL | `https://oauth2.googleapis.com/token` |
| UserInfo URL | `https://openidconnect.googleapis.com/v1/userinfo` |

## GitHub Login

1. Open GitHub **Settings / Developer settings / OAuth Apps**.
2. Create a new OAuth App.
3. Set Homepage URL to your current site domain.
4. Set Authorization callback URL to `https://your-domain.com/auth/oauth/callback/github`.
5. Copy the Client ID and generate a Client Secret.

| Creght field | Value |
| --- | --- |
| Provider Key | `github` |
| Display Name | `GitHub` |
| Redirect URL | `https://your-domain.com/auth/oauth/callback/github` |
| Scopes | `read:user,user:email` |
| Issuer | `https://github.com` |
| Authorization URL | `https://github.com/login/oauth/authorize` |
| Token URL | `https://github.com/login/oauth/access_token` |
| UserInfo URL | `https://api.github.com/user` |

## Ask AI to Add Login UI

> Add a login page with Google and GitHub login buttons.

> Add a member center. Visitors who are not signed in should see all enabled OAuth providers. Signed-in users should see their avatar, name, email, and logout button.

## Test and Troubleshoot

- Test on the same domain used in the OAuth callback URL.
- If you see `redirect_uri_mismatch`, compare the callback URL character by character.
- If the site domain changes, update the callback URL in Google/GitHub and in the Creght provider settings.
- If GitHub needs preview and production domains, create separate OAuth Apps or update the OAuth App for the active domain.
- If Google only works for test accounts, check the consent screen publishing status and test users.

## Security Notes

- Never paste Client Secrets into page code or public content.
- Use HTTPS for OAuth callbacks.
- Keep scopes minimal.
- Rotate exposed secrets immediately.

## References

- [Google OAuth 2.0 for web server applications](https://developers.google.com/identity/protocols/oauth2/web-server)
- [Google OpenID Connect redirect URI guide](https://developers.google.com/identity/openid-connect/openid-connect)
- [GitHub Docs: Creating an OAuth app](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app)

On this page

- [Before You Start](#before-you-start)
- [Find the Creght Callback URL](#find-the-creght-callback-url)
- [Google Login](#google-login)
- [GitHub Login](#github-login)
- [Ask AI to Add Login UI](#ask-ai-to-add-login-ui)
- [Test and Troubleshoot](#test-and-troubleshoot)
- [Security Notes](#security-notes)
- [References](#references)

![Creght](https://ugc.talizen.com/_assets/site/2061660904709165056/1780797461299__creght_logo.png)

This website is built with [Creght](/)

[Discord](https://discord.gg/Qvq2nmZNnb)

## Links

- [Pricing](/price)
- [Help Center](/help)
- [Contact Us](/contact)
- [Blog](/blogs)
- [Refund Policy](/tuikuan)

## Resources

- [All Resources](/resources)
- [Templates](/templates)
- [Components](https://creghtlib.site.creght.com)
- [Animations](/effects)
- [Figma to Creght](/figma2creght)
- [API for AI](/api)

## Terms

- [Terms of Service](/legal/terms)
- [Privacy Policy](/legal/privacy)
- [Acceptable Use Policy](/legal/acceptable-use)

## Social Media

- [Twitter](https://twitter.com)
- [Facebook](https://www.facebook.com)
- [LinkedIn](https://www.linkedin.com)

[蜀ICP备2023038192号-2](https://beian.miit.gov.cn)
