{"repo":"plotor/oauth4j","free":true,"listed":false,"github":"https://github.com/plotor/oauth4j","clone":"git clone https://github.com/plotor/oauth4j.git","description":"OAuth 2.0 Protocol Implementation for Java.","language":"Java","stars":11,"topics":["oauth2"],"license":"Apache-2.0","category":"auth-billing-email","readme_excerpt":"OAuth 2.0 授权协议实现 本项目为 RFC6749 协议的标准实现，主要用于对该协议的学习和理解，也可以在此基础上结合自己的业务场景做相应的改造，用于生产环境授权。 项目采用 java 语言开发，基于 SSM 框架，开发和运行环境如下： - 数据库: MySQL 5.7 - jdk: 1.8 - maven：3.2.5 本项目主要实现了协议 RFC6749 定义的 授权码授权模式 和 隐式授权模式 ，并参考协议文档 “HTTP Authentication: MAC Authentication” 实现了 MAC 类型的令牌。 相关博文： - OAuth 2.0 开放授权那些事儿 --- 一. 接口说明 项目相关表结构定义以及测试数据均放在 sqls 目录下。 注意： 实际应用中请强制开启 HTTPS ! 1.1 授权码模式 1. 请求获取授权码 路径： /oauth/code 方法： GET 参数： 参数名称 必须 类型 备注 --- --- --- --- client id 是 long 申请应用时分配的应用 ID redirect uri 是 string 回调地址 response type 是 string 授权类型， 这里 response type=code scope 否 string 开放数据接口权限 ID，可以传递多个，用空格分隔，如果不设置则适用该 APP 允许的所有权限代替。 state 否 string 随机字符串，授权请求成功后原样返回，该参数用于防止 CSRF 攻击 skip confirm 否 boolean 已登录用户会看到切换帐号的页面, 如果应用不需要切换帐号, 可以加上参数 skip confirm=true force login 否 boolean 是否强制要登录，默认为 false 请求示例： 响应： - 成功 如果授权成功，授权服务器会重定向请求到 redirect uri 所指定的地址，并带上相关参数： 返回值说明： 参数名称 必须 类型 备注 --- --- --- --- code 是 string 用来换取 access token 的授权码，有效期为 10 分钟且只能使用一次 state 否 string 如果请求时传递该参数，会原封不动回传 - 失败 如果授权失败，授权服务器会重定向请求到 redirect uri 所指定的地址，并带上相关参数： 返回值说明： 参数名称 必须 类型 备注 --- --- --- --- error 是 int 错误码] error description 是 string 错误描述信息 state 否 string 如果请求时传递该参数，会原封不动回传 2. 请求下发访问令牌 路径： /oauth/token 方法： GET 参数： 参数名称 必须 类型 备注 --- --- --- --- client id 是 long 申请应用时分配的应用 ID redirect uri 是 string 回调地址 grant type 是 string 授权码模式下 grant type=authorization code client secret 是 string 申请应用时分配的 secret，用于保证请求的真实性 code 是 string 接口 1 中下发的授权码 token type 否 string 令牌类型，可以是 bearer 或 mac，默认为 mac issue refresh token 否 boolean 是否下发刷新令牌，","default_branch":null,"files":null,"tree":[],"storefront":"/r/plotor","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/plotor/oauth4j/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}