Base structure to creating RESTful Webservice API using Slim Framework. Support Token Authentification.
Creating a new Token for user, need username and password to validate.
...\resapi\Setup.php
// add middleware
$this->add(new MiddlewareMediatype());
$this->add(new MiddlewareAuthenticator(true));
URI:
POST /create-api-token
Headers:
Content-Type : application/json
Body:
{"username":"lemke","password":"Powlqd.-!123"}
{
"0": 201,
"message": "key telah berhasil dibuat",
"username": "lemke",
"api key": "5fe1d328-09a9-5fef-a38a-7f3144a9b71a"
}
Headers:
Content-Type : application/json
WWW-Authorization : base64(username/password)
API-Token : Token