Skip to content

jeins/basic-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic Slim RESTful + Token Auth

Base structure to creating RESTful Webservice API using Slim Framework. Support Token Authentification.

Routing Create Token

Creating a new Token for user, need username and password to validate.

1. Disable UnprotectedURI

...\resapi\Setup.php

// add middleware
$this->add(new MiddlewareMediatype());
$this->add(new MiddlewareAuthenticator(true));

2. Request Token

URI:

POST /create-api-token

Headers:

Content-Type : application/json

Body:

{"username":"lemke","password":"Powlqd.-!123"}

3. Response Body

{
  "0": 201,
  "message": "key telah berhasil dibuat",
  "username": "lemke",
  "api key": "5fe1d328-09a9-5fef-a38a-7f3144a9b71a"
}

Auth By Request

Headers:

Content-Type : application/json
WWW-Authorization : base64(username/password)
API-Token : Token

About

RESTful API design with Slim Framework & Token Auth

Resources

Stars

Watchers

Forks

Packages

No packages published