matrix-spec/api/client-server/login.yaml

183 lines
6.8 KiB
YAML
Raw Normal View History

# Copyright 2016 OpenMarket 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.
2015-09-14 14:49:27 +02:00
swagger: '2.0'
info:
title: "Matrix Client-Server Registration and Login API"
2015-09-14 14:49:27 +02:00
version: "1.0.0"
host: localhost:8008
schemes:
- https
- http
basePath: /_matrix/client/%CLIENT_MAJOR_VERSION%
2015-09-14 14:49:27 +02:00
consumes:
- application/json
produces:
- application/json
securityDefinitions:
$ref: definitions/security.yaml
2015-09-14 14:49:27 +02:00
paths:
"/login":
post:
summary: Authenticates the user.
description: |-
Authenticates the user, and issues an access token they can
2015-09-14 14:49:27 +02:00
use to authorize themself in subsequent requests.
parameters:
- in: body
name: body
schema:
type: object
example: |-
{
2016-01-05 03:47:55 +01:00
"type": "m.login.password",
"user": "cheeky_monkey",
2015-09-14 14:49:27 +02:00
"password": "ilovebananas"
}
properties:
type:
type: string
description: The login type being used. Currently only "m.login.password" is supported.
user:
2015-09-14 14:49:27 +02:00
type: string
description: The fully qualified user ID or just local part of the user ID, to log in.
medium:
type: string
description: When logging in using a third party identifier, the medium of the identifier. Must be 'email'.
address:
type: string
description: Third party identifier for the user.
2015-09-14 14:49:27 +02:00
password:
type: string
description: The user's password.
required: ["type", "password"]
2015-09-14 14:49:27 +02:00
responses:
200:
description: The user has been authenticated.
examples:
application/json: |-
{
"user_id": "@cheeky_monkey:matrix.org",
"access_token": "abc123",
"home_server": "matrix.org"
}
schema:
type: object
properties:
user_id:
type: string
description: The fully-qualified Matrix ID that has been registered.
access_token:
type: string
2015-09-15 17:23:19 +02:00
description: |-
An access token for the account.
This access token can then be used to authorize other requests.
2015-09-25 14:03:46 +02:00
The access token may expire at some point, and if so, it SHOULD come with a ``refresh_token``.
2015-09-15 17:23:19 +02:00
There is no specific error message to indicate that a request has failed because
an access token has expired; instead, if a client has reason to believe its
access token is valid, and it receives an auth error, they should attempt to
refresh for a new token on failure, and retry the request with the new token.
refresh_token:
type: string
description: |-
Optional. A ``refresh_token`` may be exchanged for a new ``access_token`` using the |/tokenrefresh|_ API endpoint.
2015-09-14 14:49:27 +02:00
home_server:
type: string
description: The hostname of the homeserver on which the account has been registered.
400:
description: |-
Part of the request was invalid. For example, the login type may not be recognised.
examples:
application/json: |-
{
"errcode": "M_UNKNOWN",
"error": "Bad login type."
}
2015-09-14 14:49:27 +02:00
403:
description: |-
The login attempt failed. For example, the password may have been incorrect.
examples:
application/json: |-
{"errcode": "M_FORBIDDEN"}
429:
description: This request was rate-limited.
schema:
"$ref": "definitions/error.yaml"
tags:
- Session management
2015-09-15 17:23:19 +02:00
"/tokenrefresh":
post:
summary: Exchanges a refresh token for an access token.
description: |-
Exchanges a refresh token for a new access token.
This is intended to be used if the access token has expired.
The server MUST invalidate the supplied ``refresh_token`` if the
request is successful. It MUST also invalidate the ``access_token``
which was issued at the same time as the ``refresh_token``, if it
has not already expired.
2015-09-15 17:23:19 +02:00
security:
- accessToken: []
parameters:
- in: body
name: body
schema:
type: object
example: |-
{
"refresh_token": "a1b2c3"
}
properties:
refresh_token:
type: string
description: The refresh token which was issued by the server.
required: ["refresh_token"]
responses:
200:
description: |-
The refresh token was accepted, and a new access token has been issued.
2015-09-25 14:10:49 +02:00
The passed refresh token is no longer valid and cannot be used.
2015-09-25 14:17:11 +02:00
A new refresh token will have been returned unless some policy does
not allow the user to continue to renew their session.
2015-09-15 17:23:19 +02:00
examples:
application/json: |-
{
"access_token": "bearwithme123",
"refresh_token": "exchangewithme987"
}
schema:
type: object
properties:
access_token:
type: string
description: |-
An access token for the account.
This access token can then be used to authorize other requests.
2015-09-25 14:03:46 +02:00
The access token may expire at some point, and if so, it SHOULD come with a ``refresh_token``.
2015-09-15 17:23:19 +02:00
refresh_token:
type: string
description: Optional. A new ``refresh_token`` which may be exchanged for another new ``access_token``.
2015-09-15 17:23:19 +02:00
403:
description: |-
The exchange attempt failed. For example, the refresh token may have already been used.
examples:
application/json: |-
{"errcode": "M_FORBIDDEN"}
429:
description: This request was rate-limited.
schema:
"$ref": "definitions/error.yaml"
tags:
- Session management