更新 resource

2.0.0
monkeyk7 2018-04-21 00:35:51 +08:00
parent a5ef3b3c5b
commit c53c8c37a0
3 changed files with 34 additions and 17 deletions

View File

@ -3,24 +3,24 @@
说明:只能使用admin或unity 账号登录才能有权限访问,若使用mobile账号登录将返回Access is denied
http://localhost:8080/spring-oauth-server/oauth/authorize?client_id=unity-client&redirect_uri=http%3a%2f%2flocalhost%3a8080%2fspring-oauth-server%2funity%2fdashboard&response_type=code&scope=read
说明: 由于mobile-client只支持password,refresh_token, 所以不管用哪个账号登录后都将返回Illegal action
说明: 由于mobile-client只支持password,refresh_token, 所以不管用哪个账号登录后都将返回 OAuth Error
http://localhost:8080/spring-oauth-server/oauth/authorize?client_id=mobile-client&redirect_uri=http%3a%2f%2flocalhost%3a8080%2fspring-oauth-server%2fm%2fdashboard&response_type=code&scope=read
响应的URL如:
http://localhost:8080/spring-oauth-server/unity/dashboard.htm?code=zLl170
http://localhost:8080/spring-oauth-server/unity/dashboard?code=hGQ8qx
通过code换取access_token [POST]
http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&client_secret=unity&grant_type=authorization_code&code=zLl170&redirect_uri=http%3a%2f%2flocalhost%3a8080%2fspring-oauth-server%2funity%2fdashboard
http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&client_secret=unity&grant_type=authorization_code&code=hGQ8qx&redirect_uri=http%3a%2f%2flocalhost%3a8080%2fspring-oauth-server%2funity%2fdashboard
方式2:基于客户端 (注意参数中的username,password,对应用户的账号,密码) [POST]
http://localhost:8080/spring-oauth-server/oauth/token?client_id=mobile-client&client_secret=mobile&grant_type=password&scope=read,write&username=mobile&password=mobile
http://localhost:8080/spring-oauth-server/oauth/token?client_id=mobile-client&client_secret=mobile&grant_type=password&scope=read&username=mobile&password=mobile
说明:由于unity-client不支持password,所以若用unity-client通过password方式去授权,将返回invalid_grant
http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&client_secret=unity&grant_type=password&scope=read,write&username=mobile&password=mobile
说明:由于unity-client不支持password,所以若用unity-client通过password方式去授权,将返回 invalid_client
http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&client_secret=unity&grant_type=password&scope=read&username=mobile&password=mobile
@ -29,7 +29,7 @@ http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&cli
获取access_token后访问资源 [GET]
http://localhost:8080/spring-oauth-server/unity/dashboard.htm?access_token=3420d0e0-ed77-45e1-8370-2b55af0a62e8
http://localhost:8080/spring-oauth-server/unity/dashboard?access_token=89767569-5b78-4b26-ae2d-d361aa3e6bf9

View File

@ -7,16 +7,24 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Mobile dashboard</title>
<title>Mobile 资源</title>
</head>
<body>
<a href="../">Home</a>
<a href="${pageContext.request.contextPath}/">Home</a>
<h2>Hi Mobile.</h2>
<h2>Hi Unity
<small>你已成功访问 [mobile] 资源</small>
</h2>
Principal: <strong>${SPRING_SECURITY_CONTEXT.authentication.principal}</strong>
用户信息:
<br/>
<a href="${contextPath}/logout.do">Logout</a>
<strong>${SPRING_SECURITY_CONTEXT.authentication.principal}</strong>
<br/>
<br/>
<p class="text-info">
访问API
</p>
<a href="${pageContext.request.contextPath}/m/user_info?access_token=${param.access_token}">用户信息(JSON)</a>
</body>
</html>

View File

@ -4,19 +4,28 @@
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="tags" %>
<!DOCTYPE HTML>
<html>
<head>
<title>Unity dashboard</title>
<title>Unity 资源</title>
</head>
<body>
<a href="../">Home</a>
<a href="${pageContext.request.contextPath}/">Home</a>
<h2>Hi Unity.</h2>
<h2>Hi Unity
<small>你已成功访问 [unity] 资源</small>
</h2>
Principal: <strong>${SPRING_SECURITY_CONTEXT.authentication.principal}</strong>
用户信息:
<br/>
<a href="${contextPath}/signout">Logout</a>
<strong>${SPRING_SECURITY_CONTEXT.authentication.principal}</strong>
<br/>
<br/>
<p class="text-info">
访问API
</p>
<a href="${pageContext.request.contextPath}/unity/user_info?access_token=${param.access_token}">用户信息(JSON)</a>
</body>
</html>