当前位置:网站首页>【Oauth2】七、微信OAuth2授权登录
【Oauth2】七、微信OAuth2授权登录
2022-07-26 13:20:00 【北城小林】
前言
前面已经把gitee的OAuth2授权登录流程和配置搞明白了,单纯的理论十分枯燥,而且gitee的OAuth2中规中矩,需要我们定制的东西不多。因此这里结合微信网页开发文档来实现微信环境下的网页OAuth2授权。微信网页授权对OAuth2的一些地方进行了“夹带私货”,属于非标准的OAuth2,很多地方需要定制。这不仅仅是一个挑战,还是学习Spring Security OAuth2的一个良好素材,而且比较爽的是它提供沙盒。
本文DEMO分支:wechat 分支。
一、环境准备
在开始之前我们需要准备好微信网页开发的环境。
1、微信公众号服务号
请注意,一定是微信公众号服务号,只有服务号才提供这样的能力。一般公众号虽然也是认证过的公众号,但是只能发发文章并不具备提供服务的能力。但是微信公众平台提供了沙盒功能来模拟服务号,可以降低开发难度,你可以到微信公众号测试账号页面申请,申请成功后别忘了关注测试公众号。
正式的微信公众号服务号只有企事业单位、政府机关才能开通,微信网页开发参考文档。
2、内网穿透
因为微信服务器需要回调开发者提供的回调接口,为了能够本地调试,内网穿透工具也是必须的。启动内网穿透后,需要把内网穿透工具提供的虚拟域名配置到微信测试帐号的回调配置中,一定要按照下图所示。
配置回调地址

关注公众号

修改网页账号获取信息域名

在这里插入图片描述
二、代码配置
1、配置文件

2、自定义配置类

3、微信开发工具进行登录测试

也可以在上边地址栏中直接输入一下地址进行登录
http://iqf667.natappfree.cc/oauth2/authorization/wechat
4、登录成功后到了我们的默认页面

边栏推荐
- The parent component accesses the methods or parameters of the child component (the child component exposes the method defineexpose)
- We were tossed all night by a Kong performance bug
- B+ tree (5) introduction to MyISAM -- MySQL from getting started to mastering (17)
- 【花雕动手做】有趣好玩的音乐可视化系列小项目(13)---有机棒立柱灯
- Win11+VS2019配置YOLOX
- Niuke brush sql---2
- panic: Error 1045: Access denied for user ‘root‘@‘117.61.242.215‘ (using password: YES)
- Solve the problem that the remote host cannot connect to the MySQL database
- Click El dropdown item/@click.native
- Exploration on cache design optimization of community like business
猜你喜欢

1312_ Apply 7z command for compression and decompression

基于C#实现的学生考试系统

Kubelet CRI 容器运行时

Can I take your subdomain? Exploring Same-Site Attacks in the Modern Web

Activity.onStop() 延迟10秒?精彩绝伦的排查历程

Kubernetes flannel: host-gw mode

Elementary notes of binary tree

Learn about Pinia state getters actions plugins

MVVM architecture encapsulation of kotlin series (kotlin+mvvm)

概率论与数理统计
随机推荐
Oom caused by improper use of multithreading
Precautions for triggering pytest.main() from other files
Solution: unable to load the file c:\users\user\appdata\roaming\npm\npx PS1, because running scripts is prohibited on this system.
[typescript] typescript common types (Part 2)
B+树索引使用(6)最左原则 --mysql从入门到精通(十八)
Leetcode 217. there are duplicate elements
JSON数据传递参数&日期型参数传递
Can MySQL customize variable parameter storage functions?
Why do you want to make "secret comments"?
Sword finger offer (21): push in and pop-up sequence of stack
Detailed explanation of factory mode
时间复杂度和空间复杂度
Basic sentence structure of English ----- origin
Kubernetes Flannel:HOST-GW模式
《Kotlin系列》之MVVM架构封装(kotlin+mvvm)
1312_适用7z命令进行压缩与解压
File upload and download performance test based on the locust framework
[5g] what are Cu and Du in 5g?
Target detection network r-cnn series
JUC总结