Skip to content

JWT Authentication

v1.1.0

Built-in authentication powered by php-open-source-saver/jwt-auth.


Authentication Flow

text
Login


JWT Token


Bearer Authorization


Protected Routes

Available Endpoints

MethodEndpoint
POST/api/auth/login
GET/api/auth/me
POST/api/auth/refresh
POST/api/auth/logout

Login

POST /api/auth/login

Request:

json
{
  "email": "john@example.com",
  "password": "secret"
}

Successful response:

json
{
  "type": "success",
  "status": 200,
  "data": {
    "access_token": "...",
    "token_type": "Bearer",
    "expires_in": 3600
  }
}

Use the returned token in the Authorization: Bearer header.


Current User

GET /api/auth/me

Headers:

text
Authorization: Bearer YOUR_TOKEN

Response:

json
{
  "name": "John Doe",
  "email": "john@example.com"
}

Refresh Token

POST /api/auth/refresh

Returns a new JWT without requiring another login.


Logout

POST /api/auth/logout

Invalidates the current token.

Released under the MIT License.