代码拉取完成,页面将自动刷新
技术栈:
环境依赖:
启动流程:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: 123456
url: jdbc:mysql://127.0.0.1:3306/auth?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
公众平台用于在微信内置浏览器打开时登录
开放平台用于在非微信环境下扫码登录
social:
wx-mp: # 微信公众平台
key: xxxx
secret: xxx
wx-open: # 微信开放平台
key: xxxx
secret: xxx
captcha:
enable: true # 启用
base-str: '0123' # 随机字符
length: 4 # 长度
sms:
enable: true # 启用
secretId: 'xxxx'
secretKey: 'xxxx'
appId: 'xxx'
sign: 'xxx'
templateId: 'xxx'
baseinfo:
title: 广州王子信息科技 # 标题
beian: 粤ICP备xxxx号 # 备案号
mvn package
java -Dloader.path=./lib -jar auth-0.0.1.jar
{xxx} 表示是一个参数变量
GET /captcha?key={timestamp} HTTP/1.1
GET /sms?phone={phone} HTTP/1.1
GET /oauth/authorize?client_id={client_id}&redirect_uri={redirect_uri}&response_type={response_type}&scope={scope}&state={state} HTTP/1.1
扩展支持图形验证码,提高接口安全性
captchaKey: 图形验证码key, captchaCode: 图形验证码
POST /oauth/token HTTP/1.1
Authorization: Basic {Base64({client_id};{secret})}
Content-Type: application/x-www-form-urlencoded
grant_type=password&username={username}&password={password}&scope={scope}&captchaKey={captchaKey}&captchaCode={captchaCode}
POST /oauth/token HTTP/1.1
Authorization: Basic {Base64({client_id};{secret})}
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&code={code}&scope={scope}
if (type == 'sms')
code = '手机验证码'
if (type == 'WX_MP')
code = '微信公众平台授权码'
if (type == 'WX_OPEN')
code = '微信开放平台授权码'
POST /oauth/token HTTP/1.1
Authorization: Basic {Base64({client_id};{secret})}
Content-Type: application/x-www-form-urlencoded
grant_type=social&type={type}&code={code}&scope={scope}
{
"access_token": "access_token",
"token_type": "bearer",
"expires_in": 43199,
"scope": "read_user",
"user_id": "11"
}
GET /user_base HTTP/1.1
Authorization: Bearer {access_token}
scope!=all
{
"msg": "SUCCESS",
"code": "SUCCESS",
"name": "xxxxx"
}
scope==all
{
"msg": "SUCCESS",
"code": "SUCCESS",
"phone": "xxx",
"name": "xxx",
"email": "xxxx"
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。