- API Reference
- User
- Authenticate yourself to get an access token
Authenticate yourself to get an access token
Request
- cookieOnlyboolean
Only set the cookie and do not return cookie data.
- emailstringrequired
The users Email-Address.
- passwordstringrequired
Password of the User.
Content-Type: application/json
{
"email": "a.lovelace@example.com",
"password": "string"
}
{
"properties": {
"email": {
"description": "The users Email-Address.",
"example": "a.lovelace@example.com",
"type": "string"
},
"password": {
"description": "Password of the User.",
"type": "string"
}
},
"required": [
"email",
"password"
],
"type": "object"
}
Responses
Your authentication request was successful and you've got an access token.
- expiresstring (date-time)required
The expiration date of the token.
- refreshTokenstringrequired
Refresh token to refresh your access token even after it has expired.
- tokenstringrequired
Public token to identify yourself against the api gateway.
Content-Type: application/json
{
"expires": "1985-10-26T01:21:00.000Z",
"refreshToken": "string",
"token": "string"
}
{
"properties": {
"expires": {
"description": "The expiration date of the token.",
"format": "date-time",
"type": "string"
},
"refreshToken": {
"description": "Refresh token to refresh your access token even after it has expired.",
"type": "string"
},
"token": {
"description": "Public token to identify yourself against the api gateway.",
"type": "string"
}
},
"required": [
"token",
"refreshToken",
"expires"
],
"type": "object"
}
Multi factor authentication is activated for this user. After calling this, you need to call '/authentication/mfa' with a valid multi factor code.
- name"SecondFactorRequired"
Content-Type: application/json
{
"name": "SecondFactorRequired"
}
{
"properties": {
"name": {
"enum": [
"SecondFactorRequired"
],
"type": "string"
}
},
"type": "object"
}
Authentication failed because of wrong credentials.
- *
Content-Type: application/json
null
{
"anyOf": [
{
"type": "object",
"required": [
"type",
"validationErrors"
],
"properties": {
"type": {
"type": "string",
"enum": [
"ValidationError"
]
},
"message": {
"type": "string",
"example": "Validation failed"
},
"validationErrors": {
"type": "array",
"items": {
"type": "object",
"required": [
"message",
"path",
"type"
],
"properties": {
"message": {
"type": "string",
"description": "The standard error message",
"example": "should be string"
},
"path": {
"type": "string",
"description": "The path to the part of the data that was validated. JavaScript property access notation (e.g., \".prop[1].subProp\") is used.\n",
"example": ".address.street"
},
"type": {
"type": "string",
"description": "ajv validation error type (e.g. \"format\", \"required\", \"type\") or own validation error types",
"example": "format"
},
"context": {
"type": "object",
"example": {
"format": "email"
},
"description": "The object with the additional information about the error that can be used to create custom error messages. Keys depend on the\ntype that failed validation (e.g. \"missingProperty\" for type \"required\")\n",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
},
{
"type": "object",
"required": [
"type",
"message"
],
"properties": {
"message": {
"type": "string",
"example": "Something went wrong"
},
"type": {
"type": "string",
"example": "InternalServerError"
}
}
}
]
}
Authentication failed because of wrong credentials.
- Alternativeobject
- type"ValidationError"required
- messagestring
- validationErrorsarray of objectrequired
- Array[
- *object
- messagestringrequired
The standard error message
- pathstringrequired
The path to the part of the data that was validated. JavaScript property access notation (e.g., ".prop[1].subProp") is used.
- typestringrequired
ajv validation error type (e.g. "format", "required", "type") or own validation error types
- contextobject
The object with the additional information about the error that can be used to create custom error messages. Keys depend on the type that failed validation (e.g. "missingProperty" for type "required")
- *string
]
- Alternativeobject
- messagestringrequired
- typestringrequired
Content-Type: application/json
{
"type": "ValidationError",
"message": "Validation failed",
"validationErrors": [
{
"message": "should be string",
"path": ".address.street",
"type": "format",
"context": {
"format": "email"
}
}
]
}
Content-Type: application/json
{
"message": "Something went wrong",
"type": "InternalServerError"
}
{
"oneOf": [
{
"type": "object",
"required": [
"type",
"validationErrors"
],
"properties": {
"type": {
"type": "string",
"enum": [
"ValidationError"
]
},
"message": {
"type": "string",
"example": "Validation failed"
},
"validationErrors": {
"type": "array",
"items": {
"type": "object",
"required": [
"message",
"path",
"type"
],
"properties": {
"message": {
"type": "string",
"description": "The standard error message",
"example": "should be string"
},
"path": {
"type": "string",
"description": "The path to the part of the data that was validated. JavaScript property access notation (e.g., \".prop[1].subProp\") is used.\n",
"example": ".address.street"
},
"type": {
"type": "string",
"description": "ajv validation error type (e.g. \"format\", \"required\", \"type\") or own validation error types",
"example": "format"
},
"context": {
"type": "object",
"example": {
"format": "email"
},
"description": "The object with the additional information about the error that can be used to create custom error messages. Keys depend on the\ntype that failed validation (e.g. \"missingProperty\" for type \"required\")\n",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
},
{
"type": "object",
"required": [
"type",
"message"
],
"properties": {
"message": {
"type": "string",
"example": "Something went wrong"
},
"type": {
"type": "string",
"example": "InternalServerError"
}
}
}
]
}
Your request ran into a rate limit. You have to wait until rate limit expires
- messagestring
- typestring
Content-Type: application/json
{
"message": "too many requests",
"type": "RateLimitError"
}
{
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "too many requests"
},
"type": {
"type": "string",
"example": "RateLimitError"
}
}
}
An unexpected Error that occurred while handling the request
- messagestringrequired
- typestringrequired
Content-Type: application/json
{
"message": "Something went wrong",
"type": "InternalServerError"
}
{
"type": "object",
"required": [
"type",
"message"
],
"properties": {
"message": {
"type": "string",
"example": "Something went wrong"
},
"type": {
"type": "string",
"example": "InternalServerError"
}
}
}
Usage examples
$ curl \
--fail \
--location \
-X POST \
-d '{"email":"a.lovelace@example.com","password":"string"}' \
-H "Authorization: Bearer $MITTWALD_API_TOKEN" \
-H 'Content-Type: application/json' \
https://api.mittwald.de/v2/authenticate?cookieOnly=true
import { MittwaldAPIV2Client } from "@mittwald/api-client";
import { assertStatus } from "@mittwald/api-client-commons";
const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
const response = await client.user.authenticate({
"data": {
"email": "a.lovelace@example.com",
"password": "string"
},
"queryParameters": {
"cookieOnly": true
}
});
assertStatus(response, 200);
use \Mittwald\ApiClient\Generated\V2\Clients\User\Authenticate\AuthenticateRequest;
use \Mittwald\ApiClient\Generated\V2\Clients\User\Authenticate\AuthenticateRequestBody;
$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));
// TODO: Please consult the properties and constructor signature of
// AuthenticateRequestBody to learn how to construct a valid instance
$body = new AuthenticateRequestBody(/* TODO: ... */);
$request = (new AuthenticateRequest(
body: $body
))
->withCookieOnly(true);
$response = $client->user()->authenticate($request);
var_dump($response->getBody();