修正退出登录 api (#245)

This commit is contained in:
OceanJiang 2021-09-27 13:57:51 +08:00 committed by GitHub
parent 5e3c4e5816
commit c57e841e5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,68 +1,69 @@
# 退出账号登录
- [退出登录web端](#退出登录web端)
- [退出账号登录](#退出账号登录)
- [退出登录web 端)](#退出登录web-端)
---
## 退出登录web端
## 退出登录web 端)
> http://passport.bilibili.com/login?act=exit
> https://passport.bilibili.com/login/exit/v2
*请求方式GET*
_请求方式POST_
认证方式:仅可CookieSESSDATA
认证方式Cookie
验证登录成功后会进行删除以下cookie项
验证登录成功后会进行删除以下 cookie 项:
`DedeUserID` `DedeUserID__ckMd5` `SESSDATA` `bili_jct`
`DedeUserID` `DedeUserID__ckMd5` `SESSDATA` `bili_jct`
并在服务器注销该登录TokenSESSDATA该Token即失效
并在服务器注销该登录 TokenSESSDATA Token 即失效
**回复**
**正文参数( application/x-www-form-urlencoded **
响应为一个用于跳转html页面
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
| -------- | ---- | ------------------------- | --------------- | ---------------------------------- |
| biliCSRF | str | CSRF Token位于 cookie | Cookie 方式必要 | |
| gourl | str | 成功后跳转到的页面 | 非必要 | 默认为 `javascript:history.go(-1)` |
**json 回复:**
如果 cookie 已经失效则返回登录页面的 html 代码
根对象:
| 字段 | 类型 | 内容 | 备注 |
| ------- | ------------------------------- | -------- | ---------------------------------- |
| code | num | 返回值 | 0成功 <br />-2202csrf 请求非法 |
| status | num/不存在 | 返回值 | true成功失败时可能不存在 |
| ts | num | 返回值 | 时间戳例如1631796826 |
| message | str<br />无效时:不存在 | 错误信息 | |
| data | 有效时obj<br />无效时:不存在 | 信息本体 | |
`data`对象:
redirectUrl 重定向 url
**示例:**
```shell
curl 'http://passport.bilibili.com/login?act=exit' \
-b 'SESSDATA=xxx;DedeUserID__ckMd5=xxx;SESSDATA=xxx;bili_jct=xxx'
curl -X POST https://passport.bilibili.com/login/exit/v2 \
-b "cookie字符串" \
-d "biliCSRF=xxxxxx&gourl=https://www.bilibili.com"
```
**响应头部抓包信息:**
使用set-cookie删除了以上cookie项
<details>
<summary>查看响应示例:</summary>
```http
HTTP/1.1 200 OK
Date: Mon, 27 Jul 2020 13:42:21 GMT
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: Apache-Coyote/1.1
Set-Cookie: SESSDATA=""; Domain=.bilibili.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly
Set-Cookie: SESSDATA__ckMd5=""; Domain=.bilibili.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: SESSDATA=""; Domain=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly
Set-Cookie: SESSDATA__ckMd5=""; Domain=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: DedeUserID=""; Domain=.bilibili.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: DedeUserID__ckMd5=""; Domain=.bilibili.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: DedeUserID=""; Domain=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: DedeUserID__ckMd5=""; Domain=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: bili_jct=""; Domain=.bilibili.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: bili_jct__ckMd5=""; Domain=.bilibili.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: bili_jct=""; Domain=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: bili_jct__ckMd5=""; Domain=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: JSESSIONID=F857ED4084F8824BFDB4CD97EEC3D758; Path=/; HttpOnly
Content-Language: zh-CN
X-TKID: 1595857341658620367002
Expires: Mon, 27 Jul 2020 13:42:20 GMT
Cache-Control: no-cache
X-Cache-Webcdn: BYPASS from jd-sxhz-dx-w-01
Content-Encoding: gzip
```json
{
"code": 0,
"status": true,
"ts": 1631796826,
"data": {
"redirectUrl": "https://passport.biligame.com/crossDomain?DedeUserID=&DedeUserID__ckMd5=&SESSDATA=&bili_jct=&gourl=https%3A%2F%2Fwww.bilibili.com"
}
}
```
</details>
</details>