Skip to content

Commit 3933443

Browse files
committed
增加说明
1 parent 528ec80 commit 3933443

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

hsweb-web-oauth2/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#OAuth2 模块
2+
目前仅实现了``client_credentials``方式调用
3+
4+
## 1.引入依赖
5+
(引入``hsweb-web-starter``依赖的可忽略此步骤)
6+
```xml
7+
<dependency>
8+
<groupId>org.hsweb</groupId>
9+
<artifactId>hsweb-web-oauth2-simple</artifactId>
10+
</dependency>
11+
```
12+
13+
## 2.服务端
14+
在可进行oauth2方式调用的接口上注解 ``@Authorize(api = true)``
15+
如果已有注解,直接加上 ``api=true``属性即可
16+
17+
登录系统,在接口管理-客户端管理中建立客户端并绑定用户(api的权限即为绑定用户的权限)
18+
## 3.客户端
19+
1、申请``access_token``
20+
21+
POST请求: ``http://[host]:[port]/oauth2/access_token``
22+
23+
参数: ``grantType=client_credentials&client_id={客户端ID}&client_secret={客户端密钥}``
24+
25+
返回:
26+
```json
27+
{
28+
"access_token": "{授权码}",
29+
"token_type": "bearer",
30+
"expires_in": 3600,
31+
"scope": "public"
32+
}
33+
```
34+
2、请求接口:``http://[host]:[port]/api/yourApi?access_token={申请到的授权码}``

0 commit comments

Comments
 (0)