post/auth/sso/complete

Complete SSO

Complete the SSO authentication flow with the authorization code from the SSO provider. Returns authentication token and user information.

complete_sso

Request body

application/json

json
{
  "type": "object",
  "properties": {
    "code": {
      "type": "string",
      "description": "Authorization code from the SSO provider"
    },
    "state": {
      "type": "string",
      "description": "State parameter for CSRF protection"
    }
  },
  "required": [
    "code",
    "state"
  ]
}

Responses

200

Success

json
{
  "type": "object",
  "properties": {
    "token": {
      "type": "string",
      "description": "Authentication token for the session"
    },
    "user_id": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)$",
      "description": "ID of the authenticated user"
    },
    "user": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^(0|[1-9][0-9]*)$",
          "description": "The unique identifier (snowflake) for this user"
        },
        "username": {
          "type": "string",
          "description": "The username of the user, not unique across the platform"
        },
        "discriminator": {
          "type": "string",
          "description": "The four-digit discriminator tag of the user"
        },
        "global_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The display name of the user, if set"
        },
        "avatar": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The hash of the user avatar image"
        },
        "avatar_color": {
          "anyOf": [
            {
              "$ref": "#/components/schemas/Int32Type"
            },
            {
              "type": "null"
            }
          ],
          "description": "The dominant avatar color of the user as an integer"
        },
        "bot": {
          "type": "boolean",
          "description": "Whether the user is a bot account"
        },
        "system": {
          "type": "boolean",
          "description": "Whether the user is an official system user"
        },
        "flags": {
          "$ref": "#/components/schemas/PublicUserFlags"
        },
        "mention_flags": {
          "$ref": "#/components/schemas/MentionReplyPreferences",
          "description": "The user's account-wide reply mention preference"
        }
      },
      "required": [
        "id",
        "username",
        "discriminator",
        "global_name",
        "avatar",
        "avatar_color",
        "flags"
      ],
      "description": "Partial user data for the authenticated account"
    },
    "redirect_to": {
      "type": "string",
      "description": "URL to redirect the user to after completion"
    }
  },
  "required": [
    "token",
    "user_id",
    "user",
    "redirect_to"
  ]
}
400

Bad Request - The request was malformed or contained invalid data

json
{
  "type": "object",
  "properties": {
    "code": {
      "$ref": "#/components/schemas/APIErrorCode"
    },
    "message": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "errors": {
      "type": "array",
      "description": "Field-specific validation errors",
      "items": {
        "$ref": "#/components/schemas/ValidationErrorItem"
      }
    }
  },
  "required": [
    "code",
    "message"
  ]
}
429

Too Many Requests - You are being rate limited

json
{
  "type": "object",
  "properties": {
    "code": {
      "type": "string",
      "enum": [
        "RATE_LIMITED"
      ]
    },
    "message": {
      "type": "string"
    },
    "retry_after": {
      "type": "number",
      "description": "Seconds to wait before retrying"
    },
    "global": {
      "type": "boolean",
      "description": "Whether this is a global rate limit"
    }
  },
  "required": [
    "code",
    "message",
    "retry_after"
  ]
}
500

Internal Server Error - An unexpected error occurred

json
{
  "type": "object",
  "properties": {
    "code": {
      "$ref": "#/components/schemas/APIErrorCode"
    },
    "message": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "errors": {
      "type": "array",
      "description": "Field-specific validation errors",
      "items": {
        "$ref": "#/components/schemas/ValidationErrorItem"
      }
    }
  },
  "required": [
    "code",
    "message"
  ]
}