WanOS ID OAuth 登录
第三方网页应用可以接入 WanOS ID,使用授权码模式获取用户基础身份信息。
接口
| 地址 | 说明 |
|---|---|
| GET /oauth/authorize | 跳转 WanOS ID 授权页,公开应用不用预先创建 client_secret |
| POST /oauth/token | 授权码换 access_token / id_token;公开应用不需要 client_secret |
| GET /oauth/userinfo | Bearer token 获取用户信息,授权 points 时返回积分 |
| GET /oauth/points | 查询当前授权用户积分余额,需要 points scope |
| POST /oauth/points | 可信应用直接按 order_id 扣积分;公开应用请走确认页 |
| GET /oauth/points/authorize | 普通第三方应用跳转到官网确认扣积分,支持不传回调地址 |
授权地址示例
https://wanos.xyz/oauth/authorize?client_id=my-lan-app&app_name=局域网应用&redirect_uri=http%3A%2F%2F192.168.1.10%3A8080%2Fcallback&response_type=code&scope=openid%20profile%20points&state=random换取 Token
POST https://wanos.xyz/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&
client_id=my-lan-app&
redirect_uri=https://example.com/callback&
code=AUTH_CODE扣积分示例
POST https://wanos.xyz/oauth/points
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json
{
"amount": 5,
"order_id": "app-order-10001",
"reason": "下载附件"
}跳转确认扣积分
https://wanos.xyz/oauth/points/authorize?
client_id=my-lan-app&
app_name=局域网应用&
amount=5&
order_id=app-order-10001&
reason=下载附件&
redirect_uri=https%3A%2F%2Fexample.com%2Fpoints-callback&
state=random无回调地址
局域网应用不方便回调时,可以不传 redirect_uri。登录授权会在官网页面显示一次性授权码;扣积分确认会在官网页面直接显示扣除结果。
https://wanos.xyz/oauth/points/authorize?
client_id=my-lan-app&
app_name=局域网应用&
amount=5&
order_id=app-order-10001&
reason=下载附件