仅供开发与测试。不校验 appid/secret,固定返回一个测试用户;签名私钥公开,任何人都能伪造令牌。生产系统绝不能信任此服务。
与微信开放平台"网站应用"扫码登录 输入输出完全一致,只是域名不同:同名 WxLogin SDK、相同回跳 redirect_uri?code=&state=、相同的 /sns/* 接口与字段。
右/上方是用本站 WxLogin SDK 内嵌的二维码。手机扫码或点二维码下方"模拟扫码"→"确认登录",页面会带 code 回跳到 /wechat/callback,并自动换取 token 与用户信息。
<div id="login_container"></div>
<script src="https://mock.authn.tech/wechat/wxLogin.js"></script>
<script>
new WxLogin({
id: "login_container",
appid: "你的_appid",
scope: "snsapi_login",
redirect_uri: encodeURIComponent("https://your-app.example/callback"), // 官方约定:调用方 urlencode;回调会带 ?code=&state=
state: "任意防伪串",
style: "black", // 可选
self_redirect: false // false=顶层窗口跳转,true=iframe 内跳转
});
</script>
| JS SDK | https://mock.authn.tech/wechat/wxLogin.js |
|---|---|
| 扫码页 | https://mock.authn.tech/connect/qrconnect |
| code 换 token | https://mock.authn.tech/sns/oauth2/access_token?appid=&secret=&code=&grant_type=authorization_code |
| 刷新 token | https://mock.authn.tech/sns/oauth2/refresh_token?appid=&grant_type=refresh_token&refresh_token= |
| 用户信息 | https://mock.authn.tech/sns/userinfo?access_token=&openid= |
| 校验 token | https://mock.authn.tech/sns/auth?access_token=&openid= |
后端拿到 code 后:
curl "https://mock.authn.tech/sns/oauth2/access_token?appid=demo&secret=x&code=<CODE>&grant_type=authorization_code"
# → { access_token, expires_in, refresh_token, openid, scope, unionid }
curl "https://mock.authn.tech/sns/userinfo?access_token=<AT>&openid=<OPENID>"
# → { openid, nickname, sex, province, city, country, headimgurl, privilege, unionid }
| openid | mock-openid-oWx0000000000000000000 |
|---|---|
| unionid | mock-unionid-oUn000000000000000000 |
| nickname | 微信测试用户 |