FastAPI realizes webpage authorization to obtain basic information of WeChat users-formal environment


1. How to realize WeChat scan code login?

The overall process of this model is:

  1. The third party initiates a WeChat authorization login request. After the WeChat user allows the third-party application to be authorized, WeChat will launch the application or redirect to the third-party website, and bring the authorization temporary ticket code parameter;
  2. Add AppID and AppSecret through the code parameter and exchange for access_token through API;
  3. Use access_token to call the interface to obtain basic user data resources or help users achieve basic operations.

Get access_token sequence diagram:
Insert picture description here

2. Official account settings

Note: The official account of personal authentication does not have the authority of the webpage to obtain basic information of WeChat users

Insert picture description here
Insert picture description here

Three, configure MP_verify_lgErIaiJeOtfLiru.txt

Insert picture description here

# coding=gbk
from fastapi import FastAPI
from starlette.staticfiles import StaticFiles

app = FastAPI()
app.mount("/", StaticFiles(directory="./app/static"), name="static")

Fourth, get the developer password

Insert picture description here
To obtain AppSecret, you need to register for WeChat scan code, and then enter the official account login password.

Guess you like

Origin blog.csdn.net/qq_23934063/article/details/114934193