# OAuth

说明

此处API均使用 https://oauth.minebbs.com/oauth 为API地址

# [GET] /authorize 获取MineBBS授权

说明

请求跳转到MineBBS授权端口

e.g. https://oauth.minebbs.com/oauth/authorize?response_type=code&client_id=appid&redirect_uri=your_callback_url&scope=user:read&state=random_string

# 可用参数

[GET]

参数 类型 解释
response_type string 请求类型,固定为code
client_id string appId
redirect_uri string 回调地址,必须为https
scope string 请求范围,固定为user:read
state* string 随机字符串,可选
  • state* 添加此参数,MineBBS回调时将携带相同的值,可用于防止跨站请求伪造攻击,建议使用随机字符串,并在回调地址中验证该参数。也可以根据您的业务需求设置,如用授权后跳转到不同页面等。

# [POST] /token 获取API Token

说明

在请求跳转到授权端口后,MineBBS会引导用户进行授权,授权完成后,MineBBS会跳转回您的回调地址,并将授权码code作为参数传递给回调地址。

使用授权码访问Token端口获取API Token。

# 必要参数

# 请求头

Content-Type: application/x-www-form-urlencoded
Authorization: Basic base64(appId:appSecret)

# 请求参数

参数名 描述
client_id appId
client_secret appSecret
grant_type 请求类型固定为"code"
code 授权码
redirect_uri 回调地址,必须为https

# 响应

字段名 描述
access_token API Token
token_type 固定值为"Bearer"
expires_in 过期时间,单位为秒
refresh_token 刷新Token,用于获取新的API Token

# [POST] /revoke 撤销API Token

说明

根据您的网站业务需求,可在用户登录完成或退出登录时,将API Token进行撤销。

# 必要参数

# 请求头

Content-Type: application/x-www-form-urlencoded
Authorization: Bearer token

# 请求参数

参数名 描述
client_id appId
client_secret appSecret
token API Token