Small program development | WeChat public platform SpringBoot development example │ OAuth2.0 web page authorization application development

Enter text (such as hello) in the WeChat official account of the mobile phone, and a link of access rights will be displayed in the WeChat official account of the mobile phone, as shown in the following figure.

 

1. Create the class SNSUserInfo

Create the exofuser subpackage in the package edu.bookcode, create the entity subpackage in the package edu.bookcode.exofuser, and create the class SNSUserInfo in the package edu.bookcode.exofuser.entity. The code is shown in Example 1.

[Example 1] A code example of the class SNSUserInfo.

 

2. Create class WeixinOauth2Token

Create the class WeixinOauth2Token in the package edu.bookcode.exofuser.entity, the code is shown in Example 2.

[Example 2] Code example of class WeixinOauth2Token.

 

3. Create the class OAuth2Util

Create the util subpackage in the package edu.bookcode.exofuser, and create the class OAuth2Util in the package edu.bookcode.exofuser.util. The code is shown in Example 3.

[Example 3] Code example of class OAuth2Util.

 

4. Create the class OAuth2Controller

Create the controller subpackage in the package edu.bookcode.exofuser, and create the class OAuth2Controller in the package edu.bookcode.exofuser.controller. The code is shown in Example 4.

[Example 4] Code example of class OAuth2Controller.

 

5. Create the file user.html

Create the file user.html in the src\main\resources\templates directory of the project. The code of the file user.html is shown in Example 5.

[Example 5] The code example of the file user.html.

 

6. Run the program

After starting the intranet penetration tool, modify the relative address of AccountManageController, and run the project entry class WxgzptkfbookApplication again.

Enter text (such as "Hello") in the WeChat official account of the mobile phone, and a link of access rights is displayed in the WeChat official account of the mobile phone, as shown in Figure 2. After clicking the link in Figure 2, jump to the corresponding page (user.html), as shown in Figure 3. The output message in the console is shown in Example 6.

■ Figure 2 After entering text (such as "Hello") in the WeChat official account of the mobile phone, an access link is displayed

■ Figure 3 The result of jumping to the corresponding page (user.html) after clicking the link in Figure 2

[Example 6] An example of the output message in the console.

 

 

Guess you like

Origin blog.csdn.net/qq_41640218/article/details/127356761