From a00edf215402d234c0bc3dbc452c942c92bbbfb4 Mon Sep 17 00:00:00 2001 From: "shengzhaoli.shengz" Date: Tue, 31 Oct 2023 19:55:34 +0800 Subject: [PATCH] /oauth2/rest_token API --- .../resources/static/api/SOS_API-3.0.0.html | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/src/main/resources/static/api/SOS_API-3.0.0.html b/src/main/resources/static/api/SOS_API-3.0.0.html index f661441..ce44f5f 100644 --- a/src/main/resources/static/api/SOS_API-3.0.0.html +++ b/src/main/resources/static/api/SOS_API-3.0.0.html @@ -34,6 +34,7 @@
  • 获取access_token (grant_type=client_credentials)
  • 刷新access_token (grant_type=refresh_token)
  • +
  • 获取access_token (Restful API)
  • 检查token (/oauth2/introspect)
  • 撤销token (/oauth2/revoke)
  • [device_code]流程 - 发起认证(/oauth2/device_authorization) @@ -340,6 +341,132 @@ +
    +

    获取access_token (Restful API) + public +

    + +

    Restful API 获取access_token, + 适用于grant_type为authorization_code,refresh_token,client_credentials

    + +
      +
    • +

      + 请求URI: /oauth2/rest_token POST REST +

      + +

      + Content-Type: + application/json +

      +
      + 请求Body参数说明: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      参数名参数值必须?备注
      grant_type{grant_type}authorization_code,refresh_token,client_credentials
      scope{scope}如 openid
      client_id{client_id}
      client_secret{client_secret}
      code{code}grant_type=authorization_code时必须有
      code_verifier{code_verifier}grant_type=authorization_code + PKCE时必须有
      refresh_token{refresh_token}grant_type=refresh_token时必须有
      + 请求Body示例: +
      {
      +    "client_id": "cRG45sAr1hJ2SSKzmB5UsjPIgd7VVlM0",
      +    "client_secret": "cRG45sAr1hJ2SSKzmB5UsjPIgd7VVlM0",
      +    "grant_type": "authorization_code",
      +    "redirect_uri": "https://andaily.com/oauth2/callback",
      +    "scope": "openid profile",
      +    "code": "AL-Q-OUhhgDrG-x-nFCKILadiBA2gTgvnDYh4AaPuviiQYqPTzLl-BVDXH2VNILS4X3qnDhC7rGaiWY9Qdm9SUTAvttaSXox_g_V8Qn27PeI21xv3RFkGE21BJJWdaUB",
      +    "code_verifier": "UUdEMjhQMG1OZkF0NEFNcW12TmdOanVnaHpWeHREMGI="
      +}
      + 或 +
      {
      +    "client_id": "cRG45sAr1hJ2SSKzmB5UsjPIgd7VVlM0",
      +    "client_secret": "cRG45sAr1hJ2SSKzmB5UsjPIgd7VVlM0",
      +    "grant_type": "refresh_token",
      +    "refresh_token": "-ETmWRoPkWvH2bC4ufB2fZwyeXXaqwmUq17zS_vEGGHb9dHnXd1W8HRZnUCEP03kJEn0IQ5w8E6jyAYb_oDC3iTgbT0OwRmIbnKWbcqbp5uxjB4RpNKBtyUMxax-EU1_"
      +}
      + +
      +
      + + 响应 + +
        +
      • +
        + 正常 [200]
        +
        {
        +    "access_token": "eyJraWQiOiJzb3MtcnNhLWtpZDIiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImF1ZCI6ImNSRzQ1c0FyMWhKMlNTS3ptQjVVc2pQSWdkN1ZWbE0wIiwibmJmIjoxNjk4NzUyNTQzLCJzY29wZSI6WyJvcGVuaWQiLCJwcm9maWxlIiwiZW1haWwiXSwiaXNzIjoiaHR0cDovLzEyNy4wLjAuMTo4MDgwIiwiZXhwIjoxNjk4NzU2MTQzLCJpYXQiOjE2OTg3NTI1NDMsImp0aSI6IjU3MDA1MDQ1Nzc1MzMwMTI1OTYyMjIzNzUxNjE2MjE1In0.PlrUmTd5DUq10Sj-p2MZYoQuciVLixnsUT-RMah1eHLBvVlP4YsoCOgvzlFQQLVT8TRv-XM8JIJQCo0o151ZHhGmDzaWHEsDdPGlJvWL959LbZjw8f3BR8MvMGaBgjjMV6uWgY_nZBTef10KwWsZZwrVtR25n_qHk9SZkyFDzI6Bk7S6BvlOMFNYp80Ik8khRTwYphFykBtQQE9D8wzR59YuLP6aQVfbU8gkM6aNYmV7vYELtoQqI_Co9pOCC1Fwb7Ae-qgQzknr_FsARoui9cIgSBk7r0i5v-1fKXFC8I1idtuw-CA9GGXqNPoohDpV-e1AkygT1rbhuYavuNnv-g",
        +    "refresh_token": "L_3boxXBZFbA2odSvrrMD9tku58L_MkIAcnP8ahP2OhpuZIYDHFPqGNr0rHuhuM_1zeXu8cLKCIMsoS8leL9ZvIBJ2h84ZXs5PgcNX2jZPCedpMwTN6pKZe236Sz1Y0j",
        +    "scope": "openid profile email",
        +    "id_token": "eyJraWQiOiJzb3MtZWNjLWtpZDEiLCJhbGciOiJFUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImlzcyI6Imh0dHA6Ly8xMjcuMC4wLjE6ODA4MCIsInNpZCI6IjN3a3JXR3NucHg5SW9aQXd2d09sbkQyZ0RhTVNBSWZaazBkY2VLeHZlaVkiLCJhdWQiOiJjUkc0NXNBcjFoSjJTU0t6bUI1VXNqUElnZDdWVmxNMCIsInVwZGF0ZWRfYXQiOjAsImF6cCI6ImNSRzQ1c0FyMWhKMlNTS3ptQjVVc2pQSWdkN1ZWbE0wIiwiYXV0aF90aW1lIjoxNjk4NzUyMzQ3LCJuaWNrbmFtZSI6IiIsImV4cCI6MTY5ODc1NDM0MywiaWF0IjoxNjk4NzUyNTQzLCJqdGkiOiIyNDc3NTYyNjQxMDEwMTQxNTEyNzMwMjQ0MDQ4OTMzMyIsImVtYWlsIjoiYWRtaW5AYW5kYWlseS5jb20ifQ.k8zdBJE9aq-Tp_rz_ssUrTBxV4e8ZpKOn10s71j6xjGp7kZq1RiATrU8t00wx1RNRC4E1V62nTeYpJuTy4mdlA",
        +    "token_type": "Bearer",
        +    "expires_in": 3599
        +}
        +

        根据不同的grant_type, 返回的结果不同

        +
        +
      • +
      • +
        + 异常 [400]或[401]
        +
        {
        +    "error": "invalid_grant"
        +}
        +
        +
      • +
      +
    • +
    +
    +

    检查token (/oauth2/introspect) public @@ -837,6 +964,7 @@ "updated_at": 0, "nickname": "" } +

    具体有哪些属性值由scope范围来决定