Laravel Passport Api
This a demo rest api project using Laravel framework.
Laravel Passport provides a full OAuth2 server implementation for your Laravel application in a matter of minutes. Passport is built on top of the League OAuth2 server that is maintained by Andy Millington and Simon Hamp.
User Authentication
Method | Route | Description |
---|---|---|
POST | https://dev.mayeconcept.com.ng/api/login | Login user |
POST | https://dev.mayeconcept.com.ng/api/register | register |
POST | https://dev.mayeconcept.com.ng/api/logout | logout |
GET | https://dev.mayeconcept.com.ng/api/logout | test if you are authenticated |
GET | https://dev.mayeconcept.com.ng/api/user | get current authenticated user |
POST | https://dev.mayeconcept.com.ng/api/user | update user |
Articles
Method | Route | Description |
---|---|---|
GET | https://dev.mayeconcept.com.ng/api/articles | fetch all articles |
POST | https://dev.mayeconcept.com.ng/api/articles | create new article |
GET | https://dev.mayeconcept.com.ng/api/articles/user/{id} | get currently authenticated user single article |
GET | https://dev.mayeconcept.com.ng/api/articles/{id} | get single article |
PUT | https://dev.mayeconcept.com.ng/ api/articles/{id} | update article |
DELETE | https://dev.mayeconcept.com.ng/api/articles/{id} | delete article |
Form Data
Property Data Login email, Password register name,email,type,password,password_confirmation article title,body,author
Privileges (User Type)
Role Privilege Name 0 view post only Member 1 create,view,edit Admin 2 create,view,edit,delete Super Admin
Error Handling and Response type
Code Status Description 200 Ok The request was successfully completed 201 Created A new resource was successfully created 400 Bad Request The request was invalid 401 Unauthorized Invalid login credentials 403 Forbidden You do not have enough permission to perform this action 404 Not found The requested resource/page not found 405 Method Not Allowed The request is not supported by the resource/ method 409 Conflict The request could not be completed due to conflict 500 Internal Server Error The request was not completed due to an internal error on the server side 503 Service Unavailable The server was unavailable Return Type: JSON
Headers
Method Type Access-Control-Allow-Methods GET, POST, PUT, DELETE, OPTIONS Access-Control-Allow-Headers X-Requested-With, Content-Type, XToken-Auth, Authorization
How it works
- Register/login via the endpoint
- Upon successful login/registration, copy the token and paste in your header
- update your profile to admin/super admin to update and delete article.
Pictorial Example with Postman
To get Familiar with the process here is an example implementation method for this API.
Enjoy this article ? drop a comment below and add your own contribution.