3306 ID/Developer guide
Sign in with 3306
3306 ID is the passport for the AI era: one account to sign in to all your sites and apps. Integrate once, and people sign in to your sites, apps and AI agents with their 3306 account in one click. This guide shows how to add “Sign in with 3306” (single sign-on and third-party login) with standard OAuth 2.0 and OpenID Connect (OIDC). People can use an email code, a password or a passkey, and people without an account sign up on the sign-in page with an email code; you integrate one standard OpenID Connect provider.
Every page of this guide has a Markdown copy (the “Markdown” link under the contents), and /llms.txt summarises the whole site.
01Quick start
- Sign in to the developer console and create an app. For a website with a backend, choose that type and store the
client_secret, which is shown only once, in your server-side secret manager. Single-page and native apps have no secret. Register each callback URL in full. Use HTTPS in production. The app's name, icon and return domain are shown to users. - At your own sign-in entry, start a short-lived transaction bound to the browser and store a random
state,nonceandcode_verifier. Redirect the user to the authorization endpoint from the discovery document with an S256code_challenge. An app works as soon as it is registered. First-time users see what will be shared and the return domain; people without an account can register on the same page with an email code. Reloading or switching language keeps the same transaction. - In the callback, compare
stateand retire the transaction, then exchange the code using the same callback URL andcode_verifier. Fetch the key matchingkidfrom JWKS and verify the RS256 signature; checkiss,aud,exp,iat,nonceandsub; then call UserInfo and compare the twosubvalues. Key your accounts on(issuer, sub). The name, picture and email may all be absent.
- Browser → Your backendThe user selects “Sign in with 3306”
- Your backend → BrowserCreate state, nonce and code_verifier; 302 to /oauth/authorize
- Browser → 3306 IDOpen the authorization endpoint with code_challenge
- 3306 ID → BrowserThe user signs in and consents; 302 to redirect_uri with code and state
- Browser → Your backendThe callback receives code and state
- Your backend → 3306 IDPOST /oauth/token with code and code_verifier
- 3306 ID → Your backendReturn access_token, id_token and refresh_token
- Your backend → 3306 IDGET /oauth/userinfo with the Bearer token
- 3306 ID → Your backendReturn sub and the granted claims
- Your backend → BrowserStart your own session
Discovery document: https://id.3306.ai/.well-known/openid-configuration. The issuer is https://id.3306.ai. Users can revoke access under Authorized apps; after that the access token can no longer read UserInfo and refreshes fail.
Creating or editing an app returns reserved_name when its name contains a protected brand, including look-alike characters, added separators and full-width forms. Use your own product name. On the sign-in and consent pages, an unverified app is headed by the callback domain, with its name and status beside the icon. A verified app is headed by its name, with the callback domain listed below.
Aliases of one mailbox (plus tags, Gmail dot variants) share the cooldown for sending codes. A code signs in only the account for the exact address it was requested for.
When the email, code or password is wrong, the sign-in page gives one generic prompt and does not reveal whether the account exists. A user whose account is disabled can contact support to appeal after proving ownership with a password or code.
02Run the examples
Download the Node server, the shared OIDC module, the single-page app and its module into one directory. You need Node 22 or later; the single-page app needs only a static HTTP server. The Node example keeps sessions in memory for ten minutes. The single-page app keeps only the pending sign-in transaction in sessionStorage.
Node example: register the callback http://127.0.0.1:8071/callback, set ID_CLIENT_ID and ID_CLIENT_SECRET, and run node node.mjs.
Single-page example: add a credential of the single-page type, register the callback http://127.0.0.1:8072/spa.html and the JavaScript origin http://127.0.0.1:8072, and run python3 -m http.server 8072 --bind 127.0.0.1.
Open the example, enter the client_id, sign in, consent and select UserInfo. Then revoke the app under Authorized apps, return to the example and select UserInfo again; the request should be refused.
03Development and going live
An app works as soon as it is registered. There is no separate sandbox:
http://localhostandhttp://127.0.0.1callbacks (any port) are always allowed, and you can keep them after launch for local development. Production callbacks must be HTTPS URLs on an authorized domain.- Anyone can sign in to an app whose domains are not yet verified. The sign-in page is headed by the actual return domain and labelled Unverified. Such an app can have up to 100 users by default; after that, new users receive
audience_limit, while people who have already authorized it are not affected. - Once every authorized domain passes the ownership check, the app shows as Verified automatically and the user cap is lifted.
Endpoints, signing keys and token formats are the same before and after launch, so going live needs no code change.
04Endpoints
All endpoints live under https://id.3306.ai. Protocol responses carry Cache-Control: no-store. Keep query strings, cookies, codes and tokens out of your logs.
Discovery and keys
GET /.well-known/openid-configuration returns the endpoint URLs and supported features. GET /oauth/jwks returns the RS256 public keys for verifying ID tokens; pick the key by kid.
Authorize: GET /oauth/authorize
| Parameter | Required | Description | Example |
|---|---|---|---|
| response_type | Yes | Always code | code |
| client_id | Yes | The credential's client_id | app_Xy12… |
| redirect_uri | Yes | Must match a registered callback URL exactly | https://notes.example.org/callback |
| scope | Yes | Space-separated; must include openid, may add profile and email | openid profile |
| state | Yes | A random value you generate; returned unchanged in the callback | 32 random bytes |
| nonce | Yes | A random value; copied into the ID token | 32 random bytes |
| code_challenge | Yes | SHA-256 of code_verifier, base64url-encoded | — |
| code_challenge_method | Yes | Always S256 | S256 |
| prompt | No | select_account offers account selection, consent forces the consent screen, none shows no page | consent |
| ui_locales | No | Interface languages in order of preference: zh, zh-Hant, en, ja, ko | en ja |
On success the user is redirected to redirect_uri?code=…&state=…. On failure, to redirect_uri?error=…&state=…. With prompt=none, error is login_required or consent_required when the user would have to sign in or consent.
Success and error callbacks carry iss. Match it exactly against the issuer saved for this login before accepting the state or exchanging the code.
Token: POST /oauth/token
The body is application/x-www-form-urlencoded. A website with a backend sends client_id and client_secret with HTTP Basic (client_secret_basic) or in the form (client_secret_post); use one method per request. Single-page and native apps send only client_id in the form.
| Parameter | Required | Description | Example |
|---|---|---|---|
| grant_type | Yes | authorization_code or refresh_token | authorization_code |
| code | For a code exchange | The code from the callback; valid for 60 seconds, usable once | — |
| code_verifier | For a code exchange | The original value generated at the start; 43–128 characters | — |
| redirect_uri | For a code exchange | The same value used in the authorization request | https://notes.example.org/callback |
| refresh_token | For a refresh | The refresh token from the previous response | — |
| client_id | Public clients | Sent in the form by credentials without a secret | app_Xy12… |
{
"access_token": "…",
"refresh_token": "…",
"token_type": "Bearer",
"expires_in": 86400,
"scope": "openid profile",
"id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ii4uLiJ9…"
}An access token lasts at most 24 hours. Every refresh issues a new refresh token and retires the old one; reusing an old refresh token revokes the whole grant. Send refreshes for one grant one at a time. An ID token is valid for 60 seconds. Suspension immediately blocks authorization, token exchange, refresh and UserInfo. An offline ID token can remain valid for 60 seconds. Relying parties must check online and end their own sessions. Revocation notifications are planned.
UserInfo: GET /oauth/userinfo
Send Authorization: Bearer ACCESS_TOKEN. POST is also accepted.
{
"sub": "kJ7c2Qf0…",
"name": "Lin Xi",
"picture": "https://id.3306.ai/oauth/picture?g=…",
"email": "lin@example.org",
"email_verified": true
}sub is always present. name requires the profile scope, and picture appears only if the user has set a photo. email and email_verified require the email scope. Apps from different developers receive different sub values.
Revoke: POST /oauth/revoke
Send token in the form, with the same client authentication as the token endpoint. Success is a 200 with no body.
Sign out: GET /oauth/logout
Opens the 3306 ID sign-out confirmation. To return to your site afterwards, pass client_id and a registered post_logout_redirect_uri. Clear your own session yourself.
Error format
The token, UserInfo and revoke endpoints answer errors with JSON and an HTTP status that is usually 400, 401 or 429:
{ "error": "invalid_grant" }A 401 carries a WWW-Authenticate header and a 429 carries Retry-After. The full list of codes is under API and errors.
Health
GET /health checks the database and signing configuration and reports status as ok when healthy.
05Generic HTTP
GET /oauth/authorize?response_type=code&client_id=CLIENT&redirect_uri=ENCODED_URI&scope=openid%20profile&state=STATE&nonce=NONCE&code_challenge=CHALLENGE&code_challenge_method=S256
Host: id.3306.ai
POST /oauth/token HTTP/1.1
Host: id.3306.ai
Content-Type: application/x-www-form-urlencoded
Authorization: Basic BASE64_FORM_ENCODED_CLIENT_COLON_SECRET
grant_type=authorization_code&code=CODE&code_verifier=VERIFIER&redirect_uri=ENCODED_URI
GET /oauth/userinfo HTTP/1.1
Host: id.3306.ai
Authorization: Bearer ACCESS_TOKEN06Python · Flask / Authlib
import os, secrets
from flask import Flask, url_for
from authlib.integrations.flask_client import OAuth
app = Flask(__name__)
app.secret_key = os.environ["SESSION_SECRET"]
idp = OAuth(app).register("id3306", client_id=os.environ["ID_CLIENT_ID"],
client_secret=os.environ["ID_CLIENT_SECRET"],
server_metadata_url="https://id.3306.ai/.well-known/openid-configuration",
client_kwargs={"scope":"openid profile email", "code_challenge_method":"S256",
"token_endpoint_auth_method":"client_secret_basic"})
@app.get("/login")
def login():
return idp.authorize_redirect(url_for("callback", _external=True),
nonce=secrets.token_urlsafe(32))
@app.get("/callback")
def callback():
token = idp.authorize_access_token()
info = idp.userinfo(token=token)
if info["sub"] != token["userinfo"]["sub"]:
return "Identity mismatch", 403
return dict(info)07PHP · jumbojett/openid-connect-php
<?php
require 'vendor/autoload.php';
use Jumbojett\OpenIDConnectClient;
$id = new OpenIDConnectClient('https://id.3306.ai', getenv('ID_CLIENT_ID'), getenv('ID_CLIENT_SECRET'));
$id->setRedirectURL(getenv('ID_CALLBACK'));
$id->setCodeChallengeMethod('S256');
$id->addScope(['openid', 'profile', 'email']);
$id->authenticate();
$info = $id->requestUserInfo();
if ($info->sub !== $id->getVerifiedClaims('sub')) { http_response_code(403); exit; }
header('Content-Type: application/json');
echo json_encode($info);08Existing platforms
- Auth.js v5: use type=oidc, id=id3306, issuer=https://id.3306.ai, clientId, clientSecret, checks=['pkce','state','nonce'] and idToken=false for UserInfo. Register /api/auth/callback/id3306 on your app. Auth.js
- WordPress: enable Use PKCE in OpenID Connect Generic Client 3.11.4 or later. Supply issuer, credentials, authorize, token, UserInfo and JWKS endpoints, set Identity Key to sub and register the callback shown by the plugin. WordPress
- Casdoor: add a Custom OAuth/OIDC provider. Set Authorize, Token and UserInfo to their discovery values and map ID to sub. Verify that the installed version sends S256 and nonce and authenticates with client_secret_basic. Casdoor
- Supabase: choose Custom OAuth/OIDC Provider, provider_type=oidc, identifier=custom:id3306, issuer=https://id.3306.ai, keep pkce_enabled and register the project callback. Supabase
- Firebase: enable Identity Platform, add provider oidc.id3306, select Authorization Code, supply issuer and credentials, and register the Firebase callback. If the hosted client cannot send S256 and nonce, complete PKCE in your own client and pass the verified ID token and raw nonce to OAuthProvider.credential and signInWithCredential. Firebase
09Sign-in button
The button artwork is served from id.3306.ai; you may also host a copy. Light and dark versions each come in English and Chinese: sign-in-light.svg, sign-in-dark.svg, sign-in-light-zh.svg, sign-in-dark-zh.svg.
The snippet below works as pasted. href points to the address on your site that starts sign-in. The button follows the system colour scheme and keeps a keyboard focus ring.
<a class="id-login" href="/login"><picture>
<source media="(prefers-color-scheme: dark)" srcset="https://id.3306.ai/id-assets/sign-in-dark.svg">
<img src="https://id.3306.ai/id-assets/sign-in-light.svg" width="216" height="48" alt="Sign in with 3306"></picture></a>
<style>.id-login{display:inline-flex;margin:8px}.id-login img{display:block}.id-login:focus-visible{outline:2px solid #485bfb;outline-offset:2px}</style>Size, clear space and misuse are covered in the brand guidelines. Never collect 3306 passwords on your own pages.
sign-in-light.svg · SVG source
<svg xmlns="http://www.w3.org/2000/svg" width="216" height="48" viewBox="0 0 216 48" role="img" aria-label="Sign in with 3306"><rect x=".5" y=".5" width="215" height="47" fill="#ffffff" stroke="#0a0a0a"/><g transform="translate(15 13) scale(.0859375)"><path d="M220 112V92C220 61.1 194.9 36 164 36H92C61.1 36 36 61.1 36 92V164C36 194.9 61.1 220 92 220H164C194.9 220 220 194.9 220 164V144" fill="none" stroke="#0a0a0a" stroke-width="28" stroke-linecap="round" stroke-linejoin="round"/><circle cx="220" cy="128" r="12" fill="#485bfb"/></g><path d="M50.5 12v24" stroke="#0a0a0a" stroke-opacity=".18"/><text x="64" y="29.5" textLength="134" lengthAdjust="spacingAndGlyphs" font-family="Charter,'Bitstream Charter',Cambria,'Noto Serif',Georgia,serif" font-size="16" font-weight="700" fill="#0a0a0a">Sign in with 3306</text></svg>sign-in-dark.svg · SVG source
<svg xmlns="http://www.w3.org/2000/svg" width="216" height="48" viewBox="0 0 216 48" role="img" aria-label="Sign in with 3306"><rect x=".5" y=".5" width="215" height="47" fill="#0a0a0a" stroke="#ffffff" stroke-opacity=".32"/><g transform="translate(15 13) scale(.0859375)"><path d="M220 112V92C220 61.1 194.9 36 164 36H92C61.1 36 36 61.1 36 92V164C36 194.9 61.1 220 92 220H164C194.9 220 220 194.9 220 164V144" fill="none" stroke="#ffffff" stroke-width="28" stroke-linecap="round" stroke-linejoin="round"/><circle cx="220" cy="128" r="12" fill="#485bfb"/></g><path d="M50.5 12v24" stroke="#ffffff" stroke-opacity=".24"/><text x="64" y="29.5" textLength="134" lengthAdjust="spacingAndGlyphs" font-family="Charter,'Bitstream Charter',Cambria,'Noto Serif',Georgia,serif" font-size="16" font-weight="700" fill="#ffffff">Sign in with 3306</text></svg>sign-in-light-zh.svg · SVG source
<svg xmlns="http://www.w3.org/2000/svg" width="216" height="48" viewBox="0 0 216 48" role="img" aria-label="用 3306 登录"><rect x=".5" y=".5" width="215" height="47" fill="#ffffff" stroke="#0a0a0a"/><g transform="translate(15 13) scale(.0859375)"><path d="M220 112V92C220 61.1 194.9 36 164 36H92C61.1 36 36 61.1 36 92V164C36 194.9 61.1 220 92 220H164C194.9 220 220 194.9 220 164V144" fill="none" stroke="#0a0a0a" stroke-width="28" stroke-linecap="round" stroke-linejoin="round"/><circle cx="220" cy="128" r="12" fill="#485bfb"/></g><path d="M50.5 12v24" stroke="#0a0a0a" stroke-opacity=".18"/><text x="133" y="30" text-anchor="middle" textLength="110" lengthAdjust="spacingAndGlyphs" font-family="Charter,'Bitstream Charter',Cambria,'Noto Serif','Songti SC','Noto Serif CJK SC','Source Han Serif SC','Microsoft YaHei','PingFang SC',serif" font-size="17" font-weight="700" fill="#0a0a0a">用 3306 登录</text></svg>sign-in-dark-zh.svg · SVG source
<svg xmlns="http://www.w3.org/2000/svg" width="216" height="48" viewBox="0 0 216 48" role="img" aria-label="用 3306 登录"><rect x=".5" y=".5" width="215" height="47" fill="#0a0a0a" stroke="#ffffff" stroke-opacity=".32"/><g transform="translate(15 13) scale(.0859375)"><path d="M220 112V92C220 61.1 194.9 36 164 36H92C61.1 36 36 61.1 36 92V164C36 194.9 61.1 220 92 220H164C194.9 220 220 194.9 220 164V144" fill="none" stroke="#ffffff" stroke-width="28" stroke-linecap="round" stroke-linejoin="round"/><circle cx="220" cy="128" r="12" fill="#485bfb"/></g><path d="M50.5 12v24" stroke="#ffffff" stroke-opacity=".24"/><text x="133" y="30" text-anchor="middle" textLength="110" lengthAdjust="spacingAndGlyphs" font-family="Charter,'Bitstream Charter',Cambria,'Noto Serif','Songti SC','Noto Serif CJK SC','Source Han Serif SC','Microsoft YaHei','PingFang SC',serif" font-size="17" font-weight="700" fill="#ffffff">用 3306 登录</text></svg>10Troubleshooting and availability
invalid_request: check that the callback URL matches exactly, that S256 is used, and thatstateandnonceare both sent.invalid_scope:scopemust includeopenidand only scopes enabled for the app.invalid_client: check the secret, the credential type and that the credential is enabled.invalid_grant: the code is older than 60 seconds, was already used, orcode_verifierdoes not match.invalid_token: clear your session and start sign-in again.access_denied: the user cancelled; return them to your site.slow_down(HTTP 429): back off asRetry-Aftersays.
The console shows each app's recent errors and its count of successful authorizations.
If 3306 ID times out or is unavailable, ask the user to retry later and preserve their work. An existing session on your site may continue low-risk reads; for sensitive operations, confirm online with UserInfo first and refuse if you cannot. An ID token describes only the moment it was issued and is valid for 60 seconds; after a user revokes access, your site learns of it only by checking the token again. Never merge accounts on email alone.
11Terms and privacy
By integrating you accept the developer terms. The privacy notice explains how the platform handles user information. In short: state your purposes and retention, and request only the data you need; never ask for a 3306 password, imitate the authorization page or repurpose the data; apps that break the rules are suspended. Users can review and revoke access at any time under Authorized apps.
12Changelog
| Date | Change |
|---|---|
| 2026-11-27 | First release: OpenID Connect authorization code flow (PKCE S256), app registration and verification, five interface languages |
Frequently asked questions
What is 3306 ID?
3306 ID is the open sign-in platform (an identity provider, IdP) from 3306.AI: the passport for the AI era. People use one 3306 account to sign in to every website and app that integrates it, and developers add “Sign in with 3306” to their websites, apps or AI agents with standard OAuth 2.0 and OpenID Connect.
How is it different from other third-party logins?
It uses the same open standard, OpenID Connect, so ordinary client libraries work. What differs: an app works as soon as it is registered, with no manual review; third-party apps receive pairwise user IDs that cannot be matched across apps; after signing in on one integrated site, people do not type a password again on the next; and it is built for AI apps and agents, with pages in five languages.
How do I integrate it?
Three steps. 1) Register an app in the developer console and add your callback URL. 2) Send people to the authorization endpoint https://id.3306.ai/oauth/authorize using the authorization code flow with PKCE (S256). 3) In your callback, exchange the code at https://id.3306.ai/oauth/token, validate the ID token, then read UserInfo. Every endpoint is listed in the discovery document at https://id.3306.ai/.well-known/openid-configuration.
Does it cost anything?
Registering an app and using 3306 ID for sign-in is currently free of charge. An unverified app can have up to 100 authorized users by default; verifying its domains removes that cap.
Which standards does it support?
OpenID Connect on OAuth 2.0: the authorization code flow (response_type=code) with PKCE (S256), refresh tokens, UserInfo, JWKS, token revocation (RFC 7009) and RP-initiated logout. ID tokens are signed with RS256. Clients authenticate with client_secret_basic or client_secret_post, or as public clients without a secret.
After signing in on one site, do people have to sign in again on another?
No password again. Once someone signs in on any integrated site, 3306 ID keeps them signed in for 24 hours. During that time an app they have already approved signs them in directly, and an app they have not used before only asks once to confirm what it receives. People already signed in to the 3306.AI main site do not type a password either.
What if I don't have a 3306 account?
Enter your email on the sign-in page and type the 6-digit code we send. Your 3306 account is created on the spot and sign-in continues; there is nothing to register elsewhere first. Existing accounts can also sign in with a password or a passkey.