WanOS ID OAuth 登录

第三方网页应用可以接入 WanOS ID,使用授权码模式获取用户基础身份信息。

接口

地址说明
GET /oauth/authorize跳转 WanOS ID 授权页,公开应用不用预先创建 client_secret
POST /oauth/token授权码换 access_token / id_token;公开应用不需要 client_secret
GET /oauth/userinfoBearer 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=下载附件