集成JustAuth开源组件实现微信登录。
文档地址: https://just auth.wiki/oauth/we chat _ open.html
1、新建Spring Boot项目2、dependencygroupidorg.spring framework.boot/groupidartifactidspring-boot-starter-web/部署artification的ependencydependencygroupidorg.project lombok/groupidartifactidlombok/artifact id/dependencydependencygroupidme.zhyd.project groupidartifactidjustauth/artifactidversion1. 16.3/version/dependencyden groupidartifactiding artifactidversion5.7.7/version/dependencydependencygroupidcom.square up.ok http3/groupidartifartion
server.port=8160 5、启动程序6、contorllerpackagecom.yanghui.oauth.controller; import me.zhyd.oauth.config.authconfig; import me.zhyd.oauth.model.auth callback; import me.zhyd.oauth.request.auth request; import me.zhyd.oauth.request.authwechatopenrequest; import me.zhyd.oauth.utils.authstateutils; importorg.spring framework.web.bind.annotation.request mapping; importorg.spring framework.web.bind.annotation.rest controller; import javax.servlet.http.http无servlet轮询; import java.io.IOException; /** *微信扫码注册* @ classnamerestauthcontroller * @ author yh * @ date 2021/9/19 * @ version 1.0 */@ rest controller privatestringappsecret=' a 7482517235173 DDB 4083788 de 60 b 90 e '; /**回调目标的dddddd/privatestring redirecturl=' http://localhost 33608160/API/UC enter/wx/callback '; @requestmapping(/render ) ) publicvoidrenderauth ) httpservletresponseresponse ) throwsioException ) authrequestauthrequesption }@requestmapping((/callback ) (publicobjectlogin ) authcallbackcallback ) (authrequestauthrequest=getauthrequest ) ) returnauthrequest.log in (callback ); } privateauthrequestgetauthrequest ((returnnewauthwechatopenrequest ) authconfig.builder ).clientid ).clientid