赞
踩
服务鉴权API
客户端注册
接口说明
1:客户端的注册,只能委托admin账号来注册,需要提供客户端ID和密码。
2:注册的客户端,生成的TOKEN,只能调用获取TOKEN和校验TOKEN的接口,没有其他权限。
请求说明
http请求方式:GET,POST
curl -d"access_token=d854c661-4c4d-4614-9fa7-ed90d7dccb25&clientId=acme&clientSecret=acm"http://localhost:8080/uaa/register
参数说明
参数 | 是否必须 | 说明 |
access_token | 是 | Admin账号生成的访问TOKEN |
clientId | 是 | 客户端ID |
clientSecret | 是 | 客户端密码 |
返回说明
正确的Json返回结果:
{"clientId":"acme","clientSecret":"acm","scope":"CLIENT"}
错误的Json返回示例:
{"error":"insufficient_scope","error_description":"Insufficientscope for this resource","scope":"ADMIN"}
{"timestamp":1444298334486,"status":500,"error":"InternalServer Error","excepti
on":"org.springframework.security.oauth2.provider.ClientAlreadyExistsException",
"message":"Clientalready exists: acme2","path":"/uaa/register"}
删除客户端
接口说明
1:需要提供TOKEN值,且只有admin对应的TOKEN才有删除客户端的权限;
2:其他客户端如果需要删除,需要委托admin来删除
请求说明
http请求方式:GET,POST
curl http://localhost:8080/uaa/delete/acme?access_token=d854c661-4c4d-4614-9fa7-ed90d7dccb25
curl -d"access_token=d854c661-4c4d-4614-9fa7-ed90d7dccb25" http://localhost:8080/uaa/delete/acme
参数说明
参数 | 是否必须 | 说明 |
access_token | 是 | Admin账号生成的访问TOKEN |
返回说明
正确的Json返回结果:
{clientId:acme3}
错误的Json返回示例:
{"error":"insufficient_scope","error_description":"Insufficientscope for this resource","scope":"ADMIN"}
{"timestamp":1444355759168,"status":500,"error":"InternalServerError","exception":"org.springframework.security.oauth2.provider.NoSuchClientException","message":"Noclient with requested id: acm","path":"/uaa/delete/acm"}
获取TOKEN
接口说明
1:在使用前,需要先向auth-server服务注册一个客户端;
2:注册成功后,使用注册的客户端ID和密码,获取access_token
3:每个access_token都有一个有效期,在有效期内重复调用,返回相同token
请求说明
http请求方式:POST
curl -d"client_id=admin&client_secret=secret&grant_type=client_credentials"http://localhost:8080/uaa/oauth/token
参数说明
参数 | 是否必须 | 说明 |
grant_type | 是 | 获取access_token填写client_credentials |
client_id | 是 | 客户端ID |
client_secret | 是 | 客户端密码 |
返回说明
正确的Json返回结果:
{"access_token":"2777a567-1c64-4d5b-a03e-37de5d33ca4e","token_type":"bearer","expires_in":42968,"scope":"ADMIN"}
错误的Json返回示例:
{"error":"invalid_client","error_description":"Badclient credentials"}
验证TOKEN
接口说明
请求说明
http请求方式:GET,POST
curl -d"token=2777a567-1c64-4d5b-a03e-37de5d33ca4e" http://localhost:8080/uaa/oauth/check_token
curl http://localhost:8080/uaa/oauth/check_token?token=2777a567-1c64-4d5b-a03e-37de5d33ca4e
参数说明
参数 | 是否必须 | 说明 |
token | 是 | 需要被验证的token值 |
返回说明
正确的Json返回结果:
{"scope":["ADMIN"],"exp":1444333123,"client_id":"admin"}
错误的Json返回示例:
{"error":"invalid_token","error_description":"Tokenwas not recognised"}
{"error":"invalid_token","error_description":"Tokenhas expired"}Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。