{
  "swagger": "2.0",
  "info": {
    "description": "AuthServer OAuth2 API",
    "title": "AuthServer OAuth2",
    "contact": {},
    "version": "1.0"
  },
  "host": "127.0.0.1:10010",
  "basePath": "/",
  "paths": {
    "/api/v1/oauth/authorize/check": {
      "post": {
        "operationId": "checkAuthorizationCode",
        "description": "Check if the authorization code request is valid and return the application info.",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["oauth2_authorization_code_inner"],
        "summary": "Check the authorization code request.",
        "parameters": [
          {
            "description": "request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/oauth2.InnerAuthorizationCodeCheckRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerAuthorizationCodeResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerAuthorizationCodeResponse"
            }
          }
        }
      }
    },
    "/api/v1/oauth/authorize/confirmation": {
      "post": {
        "description": "Approve the authorization code grant request and redirect to the redirect_uri.",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "operationId": "ApproveAuthorizationCode",
        "tags": ["oauth2_authorization_code_inner"],
        "summary": "Approve the authorization code grant request.",
        "parameters": [
          {
            "description": "request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/oauth2.InnerAuthorizationCodeConfirmationRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerAuthorizationCodeResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerAuthorizationCodeResponse"
            }
          }
        }
      }
    },
    "/api/v1/oauth/console/application/user-authorized": {
      "get": {
        "description": "Inner query user authorized application  for console request.",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["console_inner"],
        "summary": "query user authorized application request.",
        "operationId": "getOauthApplications",
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerQueryUserAuthorizedAppsResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          }
        }
      }
    },
    "/api/v1/oauth/console/token": {
      "get": {
        "description": "Inner query token for console request.",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["console_inner"],
        "operationId": "getApplicationLatestToken",
        "summary": "query token request.",
        "parameters": [
          {
            "type": "integer",
            "name": "application_id",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerGetUserLastTokenResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          }
        }
      },
      "post": {
        "description": "revoke token for console request.",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["console_inner"],
        "summary": "console revoke token request.",
        "operationId": "revokeAuthorizedApplicationToken",
        "parameters": [
          {
            "description": "console revoke token request",
            "name": "revoke",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/oauth2.ConsoleRevokeTokenRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          }
        }
      }
    },
    "/api/v1/oauth/device/check": {
      "post": {
        "operationId": "checkUserCode",
        "description": "Check if the user_code is valid and return the device grant request info.",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["oauth2_device_inner"],
        "summary": "Check user_code for device authorization.",
        "parameters": [
          {
            "description": "user_code",
            "name": "user_code",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/oauth2.InnerDeviceCheckRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerDeviceCheckResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          }
        }
      }
    },
    "/api/v1/oauth/device/confirmation": {
      "post": {
        "operationId": "confirmAuthorization",
        "description": "User can approve or deny the device authorization request.",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["oauth2_device_inner"],
        "summary": "Confirm the device authorization request.",
        "parameters": [
          {
            "description": "confirm device authorization request",
            "name": "confirm",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/oauth2.InnerDeviceConfirmRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          },
          "404": {
            "description": "Can't find the device authorization request by user_code.",
            "schema": {
              "$ref": "#/definitions/oauth2.InnerBasicResponse"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "entity.Oauth2Scope": {
      "type": "object",
      "properties": {
        "org": {
          "type": "string"
        },
        "project": {
          "type": "string"
        }
      }
    },
    "oauth2.Action": {
      "type": "string",
      "enum": ["approve", "deny"],
      "x-enum-varnames": ["ActionApprove", "ActionDeny"]
    },
    "oauth2.Application": {
      "type": "object",
      "properties": {
        "home_page_uri": {
          "type": "string"
        },
        "logo_uri": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "oauth2.AuthorizationCodeTokenRequest": {
      "type": "object",
      "properties": {
        "client_id": {
          "type": "string"
        },
        "client_secret": {
          "type": "string"
        },
        "code": {
          "type": "string"
        },
        "grant_type": {
          "type": "string"
        },
        "redirect_uri": {
          "type": "string"
        }
      }
    },
    "oauth2.ConsoleRevokeTokenRequest": {
      "type": "object",
      "properties": {
        "application_id": {
          "type": "integer"
        },
        "org_id": {
          "type": "string"
        }
      }
    },
    "oauth2.DeviceAuthorizationRequest": {
      "type": "object",
      "properties": {
        "client_id": {
          "type": "string"
        }
      }
    },
    "oauth2.DeviceAuthorizationResponse": {
      "type": "object",
      "properties": {
        "device_code": {
          "type": "string"
        },
        "expires_in": {
          "type": "integer"
        },
        "interval": {
          "type": "integer"
        },
        "user_code": {
          "type": "string"
        },
        "verification_uri": {
          "type": "string"
        },
        "verification_uri_complete": {
          "type": "string"
        }
      }
    },
    "oauth2.DeviceTokenRequest": {
      "type": "object",
      "properties": {
        "client_id": {
          "type": "string"
        },
        "device_code": {
          "type": "string"
        },
        "grant_type": {
          "type": "string"
        }
      }
    },
    "oauth2.ErrorResponse": {
      "type": "object",
      "properties": {
        "error": {
          "type": "string"
        },
        "error_description": {
          "type": "string"
        },
        "error_uri": {
          "type": "string"
        }
      }
    },
    "oauth2.InnerAuthorizationCodeCheckRequest": {
      "type": "object",
      "properties": {
        "client_id": {
          "type": "string"
        },
        "redirect_uri": {
          "type": "string"
        },
        "response_type": {
          "type": "string"
        },
        "scope": {
          "type": "string"
        },
        "state": {
          "type": "string"
        }
      }
    },
    "oauth2.InnerAuthorizationCodeConfirmationRequest": {
      "type": "object",
      "properties": {
        "client_id": {
          "type": "string"
        },
        "org_id": {
          "description": "Accept OrgId \u0026 ProjectID as a string to prevent overflow in the frontend.",
          "type": "string"
        },
        "project_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "redirect_uri": {
          "type": "string"
        },
        "response_type": {
          "type": "string"
        },
        "scope": {
          "type": "string"
        },
        "state": {
          "type": "string"
        }
      }
    },
    "oauth2.InnerAuthorizationCodeResponse": {
      "type": "object",
      "properties": {
        "application": {
          "$ref": "#/definitions/oauth2.Application"
        },
        "code": {
          "type": "integer"
        },
        "message": {
          "type": "string"
        },
        "need_redirect": {
          "type": "boolean"
        },
        "redirect_to": {
          "type": "string"
        }
      }
    },
    "oauth2.InnerBasicResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "oauth2.InnerDeviceCheckRequest": {
      "type": "object",
      "properties": {
        "user_code": {
          "type": "string"
        }
      }
    },
    "oauth2.InnerDeviceCheckResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer"
        },
        "data": {
          "type": "object",
          "properties": {
            "created_at": {
              "type": "string"
            },
            "ip": {
              "type": "string"
            },
            "user_agent": {
              "type": "string"
            }
          }
        },
        "message": {
          "type": "string"
        }
      }
    },
    "oauth2.InnerDeviceConfirmRequest": {
      "type": "object",
      "properties": {
        "action": {
          "$ref": "#/definitions/oauth2.Action"
        },
        "org_id": {
          "type": "string"
        },
        "user_code": {
          "type": "string"
        }
      }
    },
    "oauth2.InnerGetUserLastTokenResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer"
        },
        "message": {
          "type": "string"
        },
        "token": {
          "$ref": "#/definitions/oauth2.InnerQueryToken"
        }
      }
    },
    "oauth2.InnerQueryToken": {
      "type": "object",
      "properties": {
        "application_id": {
          "type": "integer"
        },
        "application_logo_uri": {
          "type": "string"
        },
        "application_name": {
          "type": "string"
        },
        "created_at": {
          "type": "string"
        },
        "expire_at": {
          "type": "string"
        },
        "grant_type": {
          "type": "string"
        },
        "id": {
          "type": "integer"
        },
        "org_id": {
          "type": "string"
        },
        "scopes": {
          "$ref": "#/definitions/entity.Oauth2Scope"
        },
        "user_email": {
          "type": "string"
        },
        "user_id": {
          "type": "string"
        }
      }
    },
    "oauth2.InnerQueryTokenResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer"
        },
        "message": {
          "type": "string"
        },
        "tokens": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/oauth2.InnerQueryToken"
          }
        }
      }
    },
    "oauth2.InnerQueryUserAuthorizedAppsResponse": {
      "type": "object",
      "properties": {
        "applications": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/oauth2.UserAuthorizedApp"
          }
        },
        "code": {
          "type": "integer"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "oauth2.RefreshTokenRequest": {
      "type": "object",
      "properties": {
        "client_id": {
          "type": "string"
        },
        "client_secret": {
          "type": "string"
        },
        "grant_type": {
          "type": "string"
        },
        "refresh_token": {
          "type": "string"
        }
      }
    },
    "oauth2.RevokeTokenRequest": {
      "type": "object",
      "properties": {
        "client_id": {
          "type": "string"
        },
        "client_secret": {
          "type": "string"
        },
        "token": {
          "type": "string"
        },
        "token_type_hint": {
          "type": "string"
        }
      }
    },
    "oauth2.TokenResponse": {
      "type": "object",
      "properties": {
        "access_token": {
          "type": "string"
        },
        "expires_in": {
          "type": "integer"
        },
        "refresh_token": {
          "type": "string"
        },
        "token_type": {
          "type": "string"
        }
      }
    },
    "oauth2.UserAuthorizedApp": {
      "type": "object",
      "properties": {
        "authorized": {
          "type": "boolean"
        },
        "company": {
          "type": "string"
        },
        "company_uri": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "grant_typ": {
          "type": "string"
        },
        "home_page_uri": {
          "type": "string"
        },
        "id": {
          "type": "integer"
        },
        "last_used_at": {
          "type": "string"
        },
        "logo_uri_dark": {
          "type": "string"
        },
        "logo_uri_light": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    }
  }
}
