{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "AuthorizationGrantInput",
  "description": "Input for the authorization grant policy.",
  "type": "object",
  "properties": {
    "user": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "session_counts": {
      "description": "How many sessions the user has.\n Not populated if it's not a user logging in.",
      "anyOf": [
        {
          "$ref": "#/definitions/SessionCounts"
        },
        {
          "type": "null"
        }
      ]
    },
    "client": {
      "type": "object",
      "additionalProperties": true
    },
    "scope": {
      "type": "string"
    },
    "grant_type": {
      "$ref": "#/definitions/GrantType"
    },
    "requester": {
      "$ref": "#/definitions/Requester"
    }
  },
  "required": [
    "client",
    "scope",
    "grant_type",
    "requester"
  ],
  "definitions": {
    "SessionCounts": {
      "description": "Information about how many sessions the user has",
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "format": "uint64",
          "minimum": 0
        },
        "oauth2": {
          "type": "integer",
          "format": "uint64",
          "minimum": 0
        },
        "compat": {
          "type": "integer",
          "format": "uint64",
          "minimum": 0
        },
        "personal": {
          "type": "integer",
          "format": "uint64",
          "minimum": 0
        }
      },
      "required": [
        "total",
        "oauth2",
        "compat",
        "personal"
      ]
    },
    "GrantType": {
      "type": "string",
      "enum": [
        "authorization_code",
        "client_credentials",
        "urn:ietf:params:oauth:grant-type:device_code"
      ]
    },
    "Requester": {
      "description": "Identity of the requester",
      "type": "object",
      "properties": {
        "ip_address": {
          "description": "IP address of the entity making the request",
          "type": [
            "string",
            "null"
          ],
          "format": "ip"
        },
        "user_agent": {
          "description": "User agent of the entity making the request",
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}