OAuth 2.0 授权流程

W-ID 实现 OAuth 2.0 Authorization Code Flow,支持 PKCE 和 UserInfo。不发行 id_token,无 JWKS 端点。

授权码 + PKCE

GET /oauth/authorize?
  response_type=code&
  client_id=YOUR_CLIENT_ID&
  redirect_uri=YOUR_CALLBACK&
  scope=openid%20email%20profile&
  state=RANDOM_STATE&
  code_challenge=BASE64URL_SHA256_VERIFIER&
  code_challenge_method=S256
POST /oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&
client_id=YOUR_CLIENT_ID&
code=AUTH_CODE&
redirect_uri=YOUR_CALLBACK&
code_verifier=YOUR_PKCE_VERIFIER

Token Rotation

每次 refresh 都会返回新的 refresh token,旧 token 立即失效。

POST /oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&
client_id=YOUR_CLIENT_ID&
refresh_token=REFRESH_TOKEN

Token 撤销

POST /oauth/revoke
Content-Type: application/x-www-form-urlencoded

token=REFRESH_TOKEN&
token_type_hint=refresh_token