oauth_test - OAuth2/OIDC 独立联调客户端
这是一个完全独立的静态测试页,不依赖现有系统前端工程,用于联调你们平台的 OAuth2/OIDC 端点。
文件说明
index.html:单页联调客户端(内联 JS/CSS)README.md:使用说明
启动方式
任选其一:
- 直接双击打开
index.html - 使用任意静态服务启动(推荐,避免部分浏览器本地文件策略影响)
示例(PowerShell):
cd D:\Projects\PHP\BastionSSO\oauth_test
python -m http.server 8800
然后访问:http://localhost:8800/index.html
建议默认配置(按当前项目)
假设你的服务端是 http://localhost:
issuer:http://localhostdiscovery_endpoint:http://localhost/.well-known/openid-configurationauthorize_endpoint:http://localhost/oauth/authorizetoken_endpoint:http://localhost/oauth/tokenuserinfo_endpoint:http://localhost/oauth/userinforevoke_endpoint:http://localhost/oauth/revoke
支持流程
- Discovery 自动发现并回填端点
- Authorization Code 授权跳转
- 解析回调
code/error/state - 换取 Token(默认 Basic 优先,可切换 post)
- 拉取 UserInfo
- Refresh Token
- Revoke Token(access/refresh)
- PKCE 开关(S256)
使用步骤(推荐)
- 填写
issuer,点击“按 issuer 自动填充端点” - 填写
client_id、client_secret、redirect_uri、scope - 点击“发起授权”,在 OAuth 页面登录并同意
- 回跳后点击“解析回调”
- 点击“换取 Token”
- 点击“拉取 UserInfo”验证用户信息返回
- 可继续测试“刷新 Token”和“撤销 Token”
常见问题
invalid_client
- 检查
client_id/client_secret是否正确 - 检查客户端认证方式(Basic / post)是否与服务端一致
invalid_grant
code可能已过期或已使用redirect_uri与授权时不一致
redirect_uri mismatch
- 确保客户端配置中的回调地址与请求参数完全一致(协议/域名/端口/路径)
- 浏览器报
Failed to fetch
- 多数是 CORS 或网络策略问题
- 需要服务端放行当前 Origin,以及
Authorization/Content-Type请求头
scope相关错误
- 请求 scope 必须是客户端允许 scope 的子集
备注
- 页面配置和 token 状态会保存在浏览器
localStorage。 - 本目录不会接入现有系统菜单、路由或打包流程。