当前位置:网站首页>扫码登录的原理你真的了解吗?
扫码登录的原理你真的了解吗?
2022-04-23 16:40:00 【Always--Learning】
为什么要了解扫码登录的原理?
通过扫面二维码进行登录已经成为了一种常见的登录方式,这种方式可以在不输入用户名和密码的情况下快速的实现登录,其背后涉及到PC端、移动端和服务端三者之间的交互,无论是对前端开发者还是后端开发者而言,掌握了扫码登录的原理都可以很好的帮助我们设计一套登录机制为我们自己的应用服务。
扫码登录的主要阶段
阶段1:待扫描阶段
待扫描阶段是PC端和服务端交互的过程,主要包括以下几个步骤:
- PC端携带着自身的设备信息,向服务端发送一个请求获取二维码信息。
- 服务端生成一个唯一的二维码ID,并与这个设备进行绑定。
- 服务端向PC端返回二维码ID。
- PC端根据二维码ID展示出二维码供移动端扫描。
- PC端启动一个定时器,向服务端定时轮询,查询二维码的状态,是否被扫描,如果一段时间未被扫描的话,二维码就会失效。
阶段2:已扫描待确认阶段
这个阶段主要是移动端和服务端的交互过程,主要包括以下几个步骤:
- 移动端扫描二维码,获取二维码ID。
- 移动端将自己的身份信息token,和扫描到的二维码信息发送给服务端。
- 服务端将二维码ID和身份信息进行绑定,生成临时token。
- 服务端将临时token返回给移动端。这个临时token可以用作确认登录的凭证。
- PC端会轮询二维码的状态,将二维码的状态更新为待确认。
阶段3:已确认阶段
已确认阶段主要包括以下几个步骤:
- 移动端携带临时token,确认登录。
- 服务端收到临时token后,经过验证后,会更改二维码的状态为已确认,然后生成PC端token。
- PC端会轮询二维码的状态,并更改为已确认。
- 服务端向PC端发送二维码状态和PC端token。
- PC端凭借PC端token访问服务端API。
整体流程图
版权声明
本文为[Always--Learning]所创,转载请带上原文链接,感谢
https://jiapy.blog.csdn.net/article/details/124358680
边栏推荐
- Questions about disaster recovery? Click here
- G008-hwy-cc-estor-04 Huawei Dorado V6 storage simulator configuration
- Public variables of robotframework
- 深入了解3D模型相关知识(建模、材质贴图、UV、法线),置换贴图、凹凸贴图与法线贴图的区别
- Oak-d raspberry pie cloud project [with detailed code]
- 关于局域网如何组建介绍
- Query the data from 2013 to 2021, and only query the data from 2020. The solution to this problem is carried out
- LVM and disk quota
- 昆腾全双工数字无线收发芯片KT1605/KT1606/KT1607/KT1608适用对讲机方案
- Take according to the actual situation, classify and summarize once every three levels, and see the figure to know the demand
猜你喜欢
MySql主从复制
Dlib of face recognition framework
MySQL master-slave replication
Hyperbdr cloud disaster recovery v3 Version 2.1 release supports more cloud platforms and adds monitoring and alarm functions
第十天 异常机制
Download and install mongodb
vim编辑器的实时操作
Change the icon size of PLSQL toolbar
文件操作详解(2)
Set cell filling and ranking method according to the size of the value in the soft report
随机推荐
NVIDIA graphics card driver error
Gartner publie une étude sur les nouvelles technologies: un aperçu du métacosme
MySQL master-slave replication
Introduction to how to set up LAN
File upload and download of robot framework
Hyperbdr cloud disaster recovery v3 Version 2.1 release supports more cloud platforms and adds monitoring and alarm functions
Esxi encapsulated network card driver
VMware Workstation cannot connect to the virtual machine. The system cannot find the specified file
Kunteng full duplex digital wireless transceiver chip kt1605 / kt1606 / kt1607 / kt1608 is suitable for interphone scheme
七朋元视界可信元宇宙社交体系满足多元化的消费以及社交需求
Detailed explanation of UWA pipeline function | visual configuration automatic test
[pyGame games] how did angry birds, a mobile game that became popular all over the world 10 years ago, dominate the list? Classic return
【Pygame小游戏】10年前风靡全球的手游《愤怒的小鸟》,是如何霸榜的?经典回归......
Server log analysis tool (identify, extract, merge, and count exception information)
第十天 异常机制
Postman batch production body information (realize batch modification of data)
Hypermotion cloud migration completes Alibaba cloud proprietary cloud product ecological integration certification
Day 9 static abstract class interface
Loggie source code analysis source file module backbone analysis
JSP learning 2