当前位置:网站首页>扫码登录的原理你真的了解吗?
扫码登录的原理你真的了解吗?
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
边栏推荐
- 第九天 static 抽象类 接口
- 昆腾全双工数字无线收发芯片KT1605/KT1606/KT1607/KT1608适用对讲机方案
- MySQL的btree索引和hash索引区别
- Hyperbdr cloud disaster recovery v3 Version 2.1 release supports more cloud platforms and adds monitoring and alarm functions
- Report FCRA test question set and answers (11 wrong questions)
- 5-minute NLP: text to text transfer transformer (T5) unified text to text task model
- Install MySQL on MAC
- Best practice of cloud migration in education industry: Haiyun Jiexun uses hypermotion cloud migration products to implement progressive migration for a university in Beijing, with a success rate of 1
- Query the data from 2013 to 2021, and only query the data from 2020. The solution to this problem is carried out
- 英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
猜你喜欢

English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)

The font of the soft cell changes color

RecyclerView advanced use - to realize drag and drop function of imitation Alipay menu edit page

力扣-746.使用最小花费爬楼梯

1959年高考数学真题

Pytorch: the pit between train mode and eval mode

RAID磁盘阵列与RAID5的创建

Day 9 static abstract class interface

力扣-198.打家劫舍

Installation and management procedures
随机推荐
Gartner publie une étude sur les nouvelles technologies: un aperçu du métacosme
DDT + Excel for interface test
OMNeT学习之新建工程
On the value, breaking and harvest of NFT project
基于GPU实例的Nanopore数据预处理
The font of the soft cell changes color
How magical is the unsafe class used by all major frameworks?
昆腾全双工数字无线收发芯片KT1605/KT1606/KT1607/KT1608适用对讲机方案
Report FCRA test question set and answers (11 wrong questions)
Hyperbdr cloud disaster recovery v3 Release of version 3.0 | upgrade of disaster recovery function and optimization of resource group management function
Loggie source code analysis source file module backbone analysis
JMeter installation tutorial and solutions to the problems I encountered
ByteVCharts可视化图表库,你想要的我都有
Six scenarios of cloud migration
Ali developed three sides, and the interviewer's set of combined punches made me confused on the spot
NVIDIA显卡驱动报错
G008-hwy-cc-estor-04 Huawei Dorado V6 storage simulator configuration
Hypermotion cloud migration completes Alibaba cloud proprietary cloud product ecological integration certification
∑GL-透视投影矩阵的推导
How to upgrade openstack across versions