Coder Social home page Coder Social logo

icyux / bili-auth Goto Github PK

View Code? Open in Web Editor NEW
49.0 49.0 2.0 255 KB

第三方哔哩哔哩 OAuth 2.0 API,基于私信鉴权 | Third-party Bilibili OAuth 2.0 API

Home Page: https://bili-auth.icyu.me:41259

License: Apache License 2.0

Python 31.40% CSS 6.17% JavaScript 52.59% HTML 8.74% Dockerfile 1.10%
bilibili bilibili-api bot oauth oauth2

bili-auth's People

Contributors

icyux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bili-auth's Issues

refresh token required

哔哩哔哩鉴权使用的是 Cookie 中的 SESSDATA 字段,其中含有一个数字大概率是 Unix 时间戳。最近发现, Cookie 失效时间远远早于此时间戳规定的有效期(约半年)。

在抓取登录请求时发现 API 返回了一个名为 refresh_token 的字段,由此推测是近期更改了鉴权机制设计,SESSDATA 作为临时 Token,使用 refresh_token 作为刷新令牌。

后续考虑研究 refresh_token 机制并且在 bili-auth 中模拟,以避免令牌失效。

关于该项目的一些想法

一年前由于要开展年报活动,需要b站的鉴权,参考您的思路编写了一个oauth的实现和前端实现.
今天偶然再次翻阅到这个项目,想谈一谈实践中出现的问题和解决方案。

  1. 移动端(Android和IOS)用户占比不可忽视,而在移动端链接跳转Web对话页面(https://message.bilibili.com/#/whisper/mid${botUid})的体验是不佳的。第一,用户可能没有在浏览器登录B站;其次,B站在移动端没有对该界面进行适配,操作体验不佳。我们的改进方案是,前端通过UA判断客户端类型,在移动端采用URL Scheme跳转打开该用户的主页(即bilibili://space/${botUid}),实际体验效果良好。
  2. 对于在网站中因为防盗链无法引用B站头像的问题,事实上B站的防盗链只是校验了referer,甚至允许空referer,只需要为图像添加noreferrer属性即可。
  3. 在我们完成年报活动后,B站似乎对私信进行了一些限制,未互关的用户每日发送消息条数存在限制。但是我最近测试发现,只要关注后就可以发送多条消息,通过私信鉴权还是存在实用性的。

我们在去年的年报活动中,oauth服务经过了1w次以上的调用,工作良好。事实证明普通用户也能够理解并使用这种第三方的鉴权项目。

redirect URL check

redirect URL should be matched with the specified beginning, just like what GitHub does.

用户信息缓存

调用B站 API 获取用户基本信息时,将结果缓存下来,再加上有效期,下次请求时直接返回缓存信息即可。

获取缓存用户信息的 API 应设计为需要鉴权。用户可以凭验证请求的令牌查询此用户对应的用户信息,第四方应用可使用有效的应用凭据查询已授权此应用的用户对应信息。除此之外的请求均拒绝。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.