当前位置:网站首页>[oauth2] VII. Wechat oauth2 authorized login

[oauth2] VII. Wechat oauth2 authorized login

2022-07-26 13:30:00 Beicheng Xiaolin

Preface

I've put gitee Of OAuth2 The authorized login process and configuration are clear , Simple theory is very boring , and gitee Of OAuth2 The compasses , There are not many things we need to customize . Therefore, this paper combines wechat web page development documents to realize web pages in wechat environment OAuth2 to grant authorization . Wechat web page authorization is for OAuth2 In some places of “ Bring in private goods ”, Non standard OAuth2, Many places need customization . This is not just a challenge , Or learn Spring Security OAuth2 A good material for , And the cool thing is that it provides sandbox .
this paper DEMO Branch :wechat Branch .

One 、 Environmental preparation

Before we start, we need to prepare the wechat web development environment .

1、 WeChat official account No.

Please note that , It must be wechat official account service number , Only the service number can provide such capability . Although the general official account is also a certified official account , However, it can only send articles and does not have the ability to provide services . However, wechat public platform provides sandbox function to simulate service number , Can reduce the difficulty of development , You can go to Wechat official account test account Page application , Don't forget to pay attention to the official account after successful application. .
The official wechat official account service number is only for enterprises and institutions 、 Only government organs can be opened , Wechat web development reference documents .

2、 Intranet through

Because the wechat server needs to callback the callback interface provided by the developer , To be able to debug locally , Intranet penetration tools are also necessary . After starting intranet penetration , You need to configure the virtual domain name provided by the intranet penetration tool into the callback configuration of wechat test account , Be sure to follow the figure below .

  • Configure callback address

  • Official account
     Insert picture description here

  • Modify the web account to obtain the information domain name  Insert picture description here

Insert picture description here

Two 、 Code configuration

1、 The configuration file

 Insert picture description here

2、 Custom configuration class

 Insert picture description here

3、 Wechat development tool for login test

 Insert picture description here
You can also directly enter the address in the upper address bar to log in

http://iqf667.natappfree.cc/oauth2/authorization/wechat

4、 After logging in successfully, we arrive at our default page

 Insert picture description here

原网站

版权声明
本文为[Beicheng Xiaolin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/207/202207261320257630.html