跳到主要内容

登录授权

DeBox授权登录是基于OAuth2.0 协议标准构建的登录系统,详细介绍

GEThttps://app.debox.pro/oauth/authorize

在DeBox App中,点击该链接,跳转至授权界面,用户在该界面点击允许或取消。用户允许授权后,页面会跳转到重定向地址,并携带 code & userId & sourse

https://app.debox.pro/oauth/authorize/?
app_id=ohpdAP9W55gyXeJ0&grant_type=authorization_code&scope=userinfo&response_type=code&
pay_info=loginTest&redirect_uri=https://docs.debox.pro/demo/a.html

Parameters

Query

redirect_uri : String 授权成功后的回调地址。当用户点击授权后,app会将获得的code作为参数回调该地址。 ,需要用encodeURIComponent编码,必须是白名单下的地址,请先配置App Domain

app_id : String 应用唯一标识,在DeBox开放平台申请

scope : String 授权域:userinfo代表用户信息授权 moment代表打赏信息授权

grant_type : String 表示授权方式是授权码:authorization_code

GEThttps://open.debox.pro/openapi/oauth2/access_token

获取第一步的 code 后,请求以下链接获取 access_token:

  curl --location --request GET
https://open.debox.pro/openapi/oauth2/access_token?
grant_type=authorization_code&code=ZDY5ZTA......FRE5
&app_id=xxxxxx&app_secret=xxxxxx&user_id=xxxxxx

Parameters

Query

grant_type : String 表示授权方式是授权码:authorization_code


code : String 第一步获取的 code

app_id : String 应用唯一标识,在DeBox开放平台申请

app_secret : String 开放平台申请的app_secret

user_id : String 授权用户的user_id

Responses

200: OK
  {
"code": 1,
"data": {
"access_token":
"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODgzOTQ4MDMsInN1YiI6IjEwMzA1O
CJ9.hbEt8JthQvo85iGkhUiPpTlcII4n3hgOYDErUDS9X2kkOnsNM27pAO_x9WP4KEE_33uFEd6GOgS
A51MlYZakb1",
"expires_in": 1,
"refresh_token": "MDBMOWYZYWYTZMRLYS01ODRHLWJKYTUTZGFIMMU1ZDEZNWM3",
"token_type": ""
},
"message": "success",
"success": true
}
401: Failed
  { 
"code": 401,
"message": "Bad Request",
"success": false
}

GEThttps://open.debox.pro/openapi/oauth2/refresh_token

刷新access_token

curl --location --request GET
https://open.debox.pro/openapi/oauth2/refresh_token?
grant_type=refresh_token&refresh_token=YTNMYMZJZMY......ZTAH
&app_id=xxxxxx&app_secret=xxxxxx&user_id=xxxxxx

Parameters

Query

grant_type : String 表示授权方式是授权码:refresh_token


refresh_token : String 第二步获取的 refresh_token

app_id : String 应用唯一标识,在DeBox开放平台申请

app_secret : String 开放平台申请的app_secret

user_id : String 授权用户的user_id

Responses

200: OK
  {
"code": 1,
"data": {
"access_token":
"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODgzOTQ4MDMsInN1YiI6IjEwMzA1O
CJ9.hbEt8JthQvo85iGkhUiPpTlcII4n3hgOYDErUDS9X2kkOnsNM27pAO_x9WP4KEE_33uFEd6GOgS
A51MlYZakbg",
"expires_in": 1,
"refresh_token": "MDBMOWYZYWYTZMRLYS01ODRHLWJKYTUTZGFIMMU1ZDEZNWM3",
"token_type": ""
},
"message": "success",
"success": true
}
401: Failed
 {
"code": 401,
"message": "Bad Request",
"success": false
}