oauth2.0

服务鉴权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

curlhttp://localhost:8080/uaa/register?access_token=d854c661-4c4d-4614-9fa7-ed90d7dccb25&clientId=acme&clientSecret=acmeSecret

 

参数说明

参数

是否必须

说明

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"}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值