Skip to content

Latest commit

 

History

History
95 lines (69 loc) · 1.54 KB

File metadata and controls

95 lines (69 loc) · 1.54 KB

REST API: Authentication

Get an access token

POST /api/v1/sessions

JSON Parameters

  • email (string, required): the email of the user to authenticate
  • password (string, required): the password of the user to authenticate
  • app_name (string, required): the name of the application making the request

Example

$ curl -H "Content-Type: application/json" \
       -X POST \
       -d '{"email": "alix@example.org", "password": "secret", "app_name": "curl request"}' \
       "https://app.flus.fr/api/v1/sessions"

Response

200 OK on success:

{
    "token": "b6d6926418cf69285f3917556e7fe7cc99c43c07cb220e5375eb325efcec5fd5"
}

400 Bad Request if the credentials are invalid:

{
    "errors": {
        "@base": [
            {"code": "invalid_credentials", "description": "The credentials are invalid."}
        ]
    }
}

400 Bad Request if a parameter is missing:

{
    "errors": {
        "app_name": [
            {"code": "presence", "description": "The app name is required."}
        ]
    }
}

Changelog

  • 2.0.0: added

Delete current session

DELETE /api/v1/session

Example

$ curl -H "Content-Type: application/json" \
       -H "Authorization: Bearer <token>" \
       -X DELETE \
       "https://app.flus.fr/api/v1/session"

Response

200 OK on success:

{}

401 Unauthorized if the request is not authenticated:

{
    "error": "The request is not authenticated."
}

Changelog

  • 2.0.3: added