OIDC 对接文档
适用于标准 OAuth2 Authorization Code + OpenID Connect(RS256 ID Token + JWKS)。
Endpoints
Discovery
https://sso.wantide.com/.well-known/openid-configurationhttps://sso.wantide.com/sso/.well-known/openid-configurationAuthorize
https://sso.wantide.com/sso/authorizeToken
https://sso.wantide.com/sso/tokenUserinfo
https://sso.wantide.com/sso/userinfoJWKS
https://sso.wantide.com/sso/jwkshttps://sso.wantide.com/sso/oauth/jwks.jsonIntrospect
https://sso.wantide.com/sso/introspectRevoke
https://sso.wantide.com/sso/revokeScope 与手机号(可选)
https://sso.wantide.com/sso/authorize?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&scope=openid%20profile%20email%20phone&state=RANDOM_STATE&nonce=RANDOM_NONCE&code_challenge=S256_CHALLENGE&code_challenge_method=S256
{"sub":"USER_ID","account":"user-account","name":"User Name","email":"user@example.com","email_verified":true,"phone_number":"+8613800138000","phone_number_verified":true}
Authorize URL 示例
默认强制 S256 PKCE。为每次请求生成随机 state、nonce 和 verifier,并在回调中验证 state。公共客户端始终需要 PKCE。
https://sso.wantide.com/sso/authorize?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&scope=openid%20profile%20email&state=RANDOM_STATE&code_challenge=S256_CHALLENGE&code_challenge_method=S256
Token 请求示例
curl -X POST 'https://sso.wantide.com/sso/token' \ -u 'YOUR_CLIENT_ID:YOUR_CLIENT_SECRET' \ -d 'grant_type=authorization_code' \ -d 'code=AUTHORIZATION_CODE' \ -d 'redirect_uri=https://example.com/callback' \ -d 'code_verifier=ORIGINAL_PKCE_VERIFIER' # 也支持 client_secret_post: curl -X POST 'https://sso.wantide.com/sso/token' \ -d 'grant_type=authorization_code' \ -d 'client_id=YOUR_CLIENT_ID' \ -d 'client_secret=YOUR_CLIENT_SECRET' \ -d 'code=AUTHORIZATION_CODE' \ -d 'redirect_uri=https://example.com/callback' \ -d 'code_verifier=ORIGINAL_PKCE_VERIFIER'
New API 服务端兼容模式
仅当 New API 无法发送 PKCE 时,在管理后台将该应用的 PKCE 策略显式设为兼容模式(require_pkce=false)。仅限能在服务端保管 Client Secret 的应用。回调地址必须与后台登记值完全一致。
https://sso.wantide.com/sso/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&response_type=code&scope=openid%20profile%20email&state=RANDOM_STATE
验证回调的 state 后,由服务端提交表单换取令牌,使用 client_secret_basic 或 client_secret_post 其中一种。仅在授权请求未使用 PKCE 时省略 verifier。使用 S256 发出的授权码始终要求原 verifier。
curl -X POST 'https://sso.wantide.com/sso/token' \ -u 'YOUR_CLIENT_ID:YOUR_CLIENT_SECRET' \ --data-urlencode 'grant_type=authorization_code' \ --data-urlencode 'code=AUTHORIZATION_CODE' \ --data-urlencode 'redirect_uri=https://example.com/callback'
客户端应验证 ID Token 的签名、issuer、audience 和有效期。回调可信时,授权错误随 state 返回。Token JSON 的常见错误包括 invalid_request、invalid_client 和 invalid_grant。
Userinfo 请求示例
curl -H 'Authorization: Bearer ACCESS_TOKEN' 'https://sso.wantide.com/sso/userinfo'
Token 响应示例
{
"access_token": "ACCESS_TOKEN",
"id_token": "RS256_ID_TOKEN",
"token_type": "Bearer",
"expires_in": 604800,
"scope": "openid profile email"
}
Userinfo 响应示例
{
"sub": "USER_ID",
"account": "user-account",
"name": "User Name",
"email": "user@example.com",
"email_verified": true,
"phone_number": "+8613800138000",
"phone_number_verified": true
}