Download the PHP package coolcode/authapi without Composer
On this page you can find all versions of the php package coolcode/authapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package authapi
coolcode/authapi
coolcode/authapi
is a Laravel package that simplifies API authentication using Laravel Sanctum. This package provides a set of endpoints for user registration, login, and logout functionality with token-based authentication.
Installation
-
Install the package via Composer:
-
Publish the Sanctum migrations:
-
Run the migrations:
- Finally, issue your Laravel Sanctum tokens when users authenticate with your API.
API Endpoints
1. Register
Endpoint: /api/register
Method: POST
Headers:
Accept: application/json
Content-Type: application/json
Request Body (form-data):
Key | Value | Type |
---|---|---|
name | test | text |
[email protected] | text | |
password | password | text |
confirm_password | password | text |
Description:
Registers a new user in the system.
2. Login
Endpoint: /api/login
Method: POST
Headers:
Accept: application/json
Content-Type: application/json
Request Body (form-data):
Key | Value | Type |
---|---|---|
[email protected] | text | |
password | password | text |
Description:
Authenticates the user and issues a Bearer token for future API requests. The token is stored in the environment variable token
.
3. Logout
Endpoint: /api/logout
Method: POST
Headers:
Accept: application/json
Content-Type: application/json
Authorization: Bearer {{token}}
Description:
Logs the authenticated user out and invalidates the Bearer token.
Usage
Once you've installed the package and set it up, you can use these endpoints in your Postman collection or any API client to handle user authentication.
Postman Example
- Register a user using the Register API.
- Login using the Login API to get the Bearer token.
- Set the token in your environment variables for future authenticated requests.
- Logout the user using the Logout API.
License
This package is open-sourced software licensed under the MIT license.