Browse Source

(143) - Add project API document

0.5
LSZ 9 years ago
parent
commit
d5d14a7938
  1. 239
      others/API/SOS_API-0.5.html
  2. 5
      others/API/bootstrap.min.css
  3. BIN
      others/API/favicon.ico
  4. 4
      src/main/webapp/index.jsp

239
others/API/SOS_API-0.5.html

@ -0,0 +1,239 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<link href="bootstrap.min.css" rel="stylesheet"/>
<title>spring-oauth-server API</title>
</head>
<body class="container">
<h2 class="page-header">spring-oauth-server
<small>V-0.5</small>
</h2>
<div class="alert alert-info">
<strong>说明</strong>: 本文档用于描述spring-oauth-server对外开发的接口(API)使用, 所有标记
<small class="badge">public</small>
的API都是公开的, 其他的API则需要获取
<mark>access_token</mark>
后可调用
</div>
<div class="row">
<div class="col-md-3">
<ul class="list-group">
<li class="list-group-item"><a href="#getAccessTokenPassword">获取access_token (grant_type=password)</a></li>
<li class="list-group-item"><a href="#getTokenAuthCode">获取access_token (grant_type=authorization_code)</a>
</li>
<li class="list-group-item"><a href="#getTokenCred">获取access_token (grant_type=client_credentials)</a></li>
<li class="list-group-item"><a href="#getTokenRest">获取access_token (Restful API)</a></li>
<li class="list-group-item"><a href="#refreshToken">刷新access_token (grant_type=refresh_token)</a></li>
<li class="list-group-item"><a href="#">获取当前用户信息 (Unity)</a></li>
<li class="list-group-item"><a href="#">获取当前用户信息 (Mobile)</a></li>
</ul>
</div>
<div class="col-md-9">
<div class="well well-sm" id="getAccessTokenPassword">
<h3>获取access_token (grant_type=password)
<small class="badge">public</small>
</h3>
<p class="text-muted">使用grant_type=password方式来获取access_token</p>
<ul class="list-group">
<li class="list-group-item">
<p>
请求URI: <code>/oauth/token</code> <span
class="label label-warning">POST</span>
</p>
<div>
请求参数说明:
<table class="table table-bordered">
<thead>
<tr>
<th>参数名</th>
<th>参数值</th>
<th>必须?</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr>
<td>client_id</td>
<td>{client_id}</td>
<td></td>
<td></td>
</tr>
<tr>
<td>client_secret</td>
<td>{client_secret}</td>
<td></td>
<td></td>
</tr>
<tr>
<td>grant_type</td>
<td>password</td>
<td></td>
<td>固定值</td>
</tr>
<tr>
<td>scope</td>
<td>{scope}</td>
<td></td>
<td>read or write</td>
</tr>
<tr>
<td>username</td>
<td>{username}</td>
<td></td>
<td>用户名</td>
</tr>
<tr>
<td>password</td>
<td>{password}</td>
<td></td>
<td>用户密码</td>
</tr>
</tbody>
</table>
请求示例:
<p>
<code>http://localhost:8080/spring-oauth-server/oauth/token?client_id=6361b08fdea6400f93b2eccda8936b32&client_secret=i4KXewMI0u6i8CFEZo10mB2rGzQRXrIv&grant_type=password&scope=read&username=mobile&password=mobile</code>
</p>
</div>
<br/>
<strong>响应</strong>
<ul class="list-group">
<li class="list-group-item">
<p>
正常 [200]<br/>
<mark>
{"access_token":"1f60abaf-6c3f-45a8-a574-bbbe6f76083f","token_type":"bearer","expires_in":41769,"scope":"read"}
</mark>
</p>
</li>
<li class="list-group-item">
<p>
异常 [401]<br/>
<mark>
&lt;oauth&gt;&lt;error_description&gt;Bad client credentials&lt;/error_description&gt;&lt;error&gt;invalid_client&lt;/error&gt;&lt;/oauth&gt;
</mark>
</p>
</li>
</ul>
</li>
</ul>
</div>
<div class="well well-sm" id="getTokenAuthCode">
<h3>获取access_token (grant_type=authorization_code)
<small class="badge">public</small>
</h3>
<p class="text-muted">使用grant_type=authorization_code 方式来获取access_token, 需要先获取code</p>
<ul class="list-group">
<li class="list-group-item">
<p>
请求URI: <code>/oauth/token</code> <span
class="label label-warning">POST</span>
</p>
<div>
请求参数说明:
<table class="table table-bordered">
<thead>
<tr>
<th>参数名</th>
<th>参数值</th>
<th>必须?</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr>
<td>client_id</td>
<td>{client_id}</td>
<td></td>
<td></td>
</tr>
<tr>
<td>client_secret</td>
<td>{client_secret}</td>
<td></td>
<td></td>
</tr>
<tr>
<td>grant_type</td>
<td>authorization_code</td>
<td></td>
<td>固定值</td>
</tr>
<tr>
<td>code</td>
<td>{code}</td>
<td></td>
<td></td>
</tr>
<tr>
<td>redirect_uri</td>
<td>{redirect_uri}</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
请求示例:
<p>
<code>http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&client_secret=unity&grant_type=authorization_code&code=[code]&redirect_uri=[redirect_uri]</code>
</p>
</div>
<br/>
<strong>响应</strong>
<ul class="list-group">
<li class="list-group-item">
<p>
正常 [200]<br/>
<mark>
{"access_token":"2c612eb7-a22b-45f0-8b2e-cd6f9e366772","token_type":"bearer","refresh_token":"6c984bdc-01c7-486f-93bf-5637990d8a37","expires_in":43199,"scope":"read
write"}
</mark>
</p>
</li>
<li class="list-group-item">
<p>
异常 [401]<br/>
<mark>
{"error":"invalid_grant","error_description":"Invalid authorization code: vzmIh1"}
</mark>
</p>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<hr/>
<p class="text-center text-muted">
&copy; 2013 - 2016
<a href="mailto:sz@monkeyk.com">sz@monkeyk.com</a> from <a
href="http://git.oschina.net/shengzhao/spring-oauth-server" target="_blank">spring-oauth-server</a>
</p>
</div>
</div>
</body>
</html>

5
others/API/bootstrap.min.css vendored

File diff suppressed because one or more lines are too long

BIN
others/API/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

4
src/main/webapp/index.jsp

@ -13,7 +13,9 @@
</head>
<body>
<h2>Spring Security&Oauth2 is work!</h2>
<h2>Spring Security&Oauth2
<small class="badge" title="Version">0.5</small>
</h2>
<p>
<a href="${contextPath}/login.jsp">Login</a>

Loading…
Cancel
Save