# Copyright 2017 Kamax.io
# Copyright 2018 New Vector Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
openapi: 3.1.0
info:
  title: Matrix Federation OpenID API
  version: 1.0.0
paths:
  /openid/userinfo:
    get:
      summary: Exchange an OpenID token for user information
      description: |-
        Exchanges an OpenID access token for information about the user
        who generated the token. Currently this only exposes the Matrix
        User ID of the owner.
      operationId: exchangeOpenIdToken
      parameters:
        - in: query
          name: access_token
          description: The OpenID access token to get information about the owner for.
          required: true
          example: SomeT0kenHere
          schema:
            type: string
      responses:
        "200":
          description: Information about the user who generated the OpenID access token.
          content:
            application/json:
              schema:
                type: object
                properties:
                  sub:
                    type: string
                    description: The Matrix User ID who generated the token.
                    example: "@alice:example.com"
                required:
                  - sub
        "401":
          description: The token was not recognized or has expired.
          content:
            application/json:
              schema:
                $ref: ../client-server/definitions/errors/error.yaml
              examples:
                response:
                  value: {
                    "errcode": "M_UNKNOWN_TOKEN",
                    "error": "Access token unknown or expired"
                  }
servers:
  - url: "{protocol}://{hostname}{basePath}"
    variables:
      protocol:
        enum:
          - http
          - https
        default: https
      hostname:
        default: localhost:8448
      basePath:
        default: /_matrix/federation/v1
