开放平台/   DEVELOPERS

OAuth 2.0 · OpenID Connect

一次授权,连接你的应用。

让你的应用接入应用宝账号登录。

每个品牌站使用独立账号体系。

登录中心https://jingweihub.com

我的应用

登录后登记应用名称与 HTTPS 回调地址。 / 服务端应用的 client_secret 仅显示一次。

登录登记

快速接入

  1. 登记应用

    在登录后登记你的应用,保存分配的 client_id 与 HTTPS 回调地址。

  2. 发起授权

    使用授权码模式(Authorization Code)并结合 PKCE 发起用户授权。

  3. 交换令牌

    在用户授权后,使用获取到的 code 与 code_verifier 向令牌端点换取令牌。

  4. 建立会话

    使用访问令牌获取用户信息,建立应用会话,并按需处理令牌撤销。

常用端点

GET
/api/public/oauth/authorize
POST
/api/public/oauth/token
GET
/api/public/oauth/userinfo
POST
/api/public/oauth/revoke
GET
/api/public/oauth/jwks

发现文档/.well-known/openid-configuration

授权参数

GET https://jingweihub.com/api/public/oauth/authorize

response_type
code
client_id
登记应用时分配的客户端编号。
redirect_uri
必须与登记的 HTTPS 回调地址完全一致。
scope
openid email — openid 必填;email 为可选授权范围。
state / nonce
为本次授权生成随机值,并在回调及 ID Token 中校验对应值。
code_challenge
BASE64URL(SHA256(code_verifier))
code_challenge_method
S256
换取与刷新令牌

POST https://jingweihub.com/api/public/oauth/token

Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&code=...&redirect_uri=...&client_id=...&code_verifier=...

服务端应用还需提交 client_secret;公开应用不传 client_secret。刷新时使用 grant_type=refresh_token,并提交 refresh_token 及客户端参数。

ID Token 使用 RS256 签名。校验签名、iss、aud、exp 和本次授权的 nonce;iss 是本页登录中心,aud 是 client_id。

用户信息与撤销

GET https://jingweihub.com/api/public/oauth/userinfo

Authorization: Bearer <access_token>

返回 sub、username、preferred_username、name。仅在授权 email 范围且账号已绑定邮箱时返回邮箱相关信息;不会返回密码。

POST https://jingweihub.com/api/public/oauth/revoke

使用表单提交 token、client_id;服务端应用还需 client_secret。退出应用时撤销令牌,并清理应用自身的会话。