password.md

August 27, 2019 · View on GitHub

Postman 接口集分享

密码模式

grant_type: password
client_id: test_client_id_1
client_secret: test_client_secret_1
username: admin
password: 123456

  • 也支持请求头验证 client:Authorization: Basic dGVzdF9jbGllbnRfaWRfMTp0ZXN0X2NsaWVudF9zZWNyZXRfMQ==

cURL

curl -X POST \
  http://sso.cdk8s.com:9091/sso/oauth/token \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'cache-control: no-cache' \
  -d 'grant_type=password&client_id=test_client_id_1&client_secret=test_client_secret_1&username=admin&password=123456'

请求参数合法,系统返回

  • 状态码 200
  • JSON 数据
{
    "access_token": "AT-MISqrbWUxFWc1xU4e8JK2OcMgJYusF22-101",
    "token_type": "Bearer",
    "expires_in": 57600,
    "refresh_token": "RT-7UPY41g9j5K8rKBZse4qo4iP6sAbU2Df-102"
}

请求参数不合法,系统返回

  • 状态码 400
  • JSON 数据
{
    "error": "invalid request",
    "error_description": "请求类型不匹配",
    "error_uri_msg": "See the full API docs at https://github.com/cdk8s"
}

用户名密码有问题,系统返回

  • 状态码 400
  • JSON 数据
{
    "error": "invalid request",
    "error_description": "用户名或密码错误",
    "error_uri_msg": "See the full API docs at https://github.com/cdk8s"
}