The principle of OAUTH2.0 WeChat account authorization login Zhihu

Problem Description

I want to access csdn, but I need to log in, but I don’t want to register again. I happen to be able to log in using WeChat.
So, here comes the question
1. Why can I log in with WeChat?
2. If the login information is on WeChat, how can I display my username?
This is because:
WeChat terminal and Zhihu terminal use Oauth2.0 protocol

Oauth2.0 protocol: How to authorize an app to access the resources of another app.

The principle is as follows

Insert picture description here

1. When you want to log in to the Zhihu page, there is an icon that can be logged in with WeChat. When you click, the front end will trigger a request to access the WeChat login page, as follows

Insert picture description here
2. As shown in the figure below: i.e. log in to the WeChat interface
Insert picture description here
3. After successful login, it will be redirected to the Zhihu interface, and the WeChat terminal will return the code code in the url.

4. Knowing that the server side will get the code code from the url, and pass the three parameters app_id, app_secret, to get the token. After getting the token, pass the token parameter to directly call the WeChat interface to get user-related information.

Guess you like

Origin blog.csdn.net/baidu_41796276/article/details/112466392