A brief discussion on the principle of WeChat QR code scanning login

A brief discussion on the principle of WeChat QR code scanning login

Preface

Hello everyone, I am programmer Amu!

When the web version of WeChat was first launched, countless people were amazed by its login method. There was no need to enter a username and password. Just open WeChat on your phone and scan to log in automatically.


Log in by scanning QR code on WeChat

Nowadays, as long as the application supports both PC and mobile terminals, it supports mobile app scanning code login, such as Taobao, 12306, etc. In principle, the QR code is just a piece of text encoding, so how does it achieve quick login? Today we will briefly analyze it!

text

If you scan the QR code with apps like WoChaCha, Alipay, or Sina Weibo, you will find that the QR code is parsed to the following URL:

https://login.weixin.qq.com/l/obsbQ-Dzdg==

Next, we will introduce each specific step of scanning code login in detail:


WeChat scan code login principle

As shown in the figure:

  • User A visits the WeChat web version, and the WeChat server generates a globally unique ID for this session. The obsbQ-Dzdg== in the above URL is this ID, but the system does not know who the visitor is at this time.
  • User A opens WeChat on his mobile phone and scans the QR code, and is prompted to confirm the login.
  • WeChat on the phone is logged in. After the user clicks to confirm the login, the WeChat client on the phone submits the WeChat account and the scanned ID to the server.
  • The server binds this ID to the WeChat account of user A and notifies the web version of WeChat that the WeChat account corresponding to this ID is user A. The web version of WeChat loads the WeChat information of user A. At this point, the entire process of scanning the code to log in is completed.

As for how the server notifies the web version of WeChat, there are only two ways:

If it is a CS application, the client uses polling to ask the server whether the login is successful.

  • If it is a BS application, the server can inform the client of successful login through CallBack.

Scanning QR code to log in seems magical, mainly because WeChat APP will do some extra operations that ordinary QR code software will not do when scanning its own code, that is, submitting the currently logged in WeChat and the scanned ID to the WeChat server. Similar applications also have functions such as scanning code to pay and scanning code to add public accounts.

Conclusion

The above is the principle of scanning code to log in. Do you understand it?

<<:  Very down-to-earth! Android 10 gets new features

>>:  Foreign media: Apple's 5G mobile phone release postponed to October due to the epidemic

Recommend

Wild Dog Programmer Independence Day Rock Music Festival will be held on April 8

Who says programmers should code in boredom? Who ...

5 formulas for brands to create influencers who can bring goods

How to create your own influencer to sell product...

This article tells you how to do video SEO marketing?

SEO video marketing starts with figuring out who ...

How to build a GuangDianTong information flow account?

Guangdiantong is an advertising platform based on...

DEVIALET MANIA - A breakthrough in high-fidelity portable audio experience

Devialet's expert engineering team brings its...

A comprehensive guide to App promotion and operation knowledge: [Data Analysis]

Part 1 How to evaluate channel quality from data ...

In 2017, AI beat humans at every game designed by humans

For much of the 20th century, chess was a benchma...

How to make Tik Tok videos popular? Tips and methods for shooting Tik Tok videos

Many friends have encountered this situation: the...

Apple iOS 16 is exposed in advance, and four new features are eye-catching

In a blink of an eye, 2022 is about to arrive in ...

Write your own Bayesian classifier to classify books

[[141939]] Background and Purpose First of all, t...

Regarding Android adaptation, it is enough to read this article

This article mainly introduces the relevant conte...

How to make your marketing reach high-value people on Zhihu?

Zhihu is a platform that brings together a group ...

Don’t buy the fruit slices sold at the roadside for 15 yuan a box!

Source: Dr. Curious The cover image and the image...