Download the PHP package smart-dato/gls-authenticator without Composer
On this page you can find all versions of the php package smart-dato/gls-authenticator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download smart-dato/gls-authenticator
More information about smart-dato/gls-authenticator
Files in smart-dato/gls-authenticator
Package gls-authenticator
Short Description Authentication API v2
License MIT
Homepage https://github.com/smart-dato/gls-authenticator
Informations about the package gls-authenticator
GLS Authentication API v2
A Laravel package for authenticating with the GLS Group Authentication API v2. This package provides a fluent, cache-enabled interface for obtaining OAuth 2.0 access tokens using the client credentials grant type.
Features
- 🔐 OAuth 2.0 Authentication - Client credentials grant type
- 💾 Automatic Token Caching - Tokens cached until expiration (4 hours)
- 🔄 Token Refresh Logic - Automatic detection and refresh of expired tokens
- 🎯 Scope Management - Request tokens with specific OAuth scopes
- 🏢 Multi-Tenant Support - Runtime configuration for different credentials
- 🌍 Environment Switching - Support for sandbox and production environments
- 🚀 Fluent API - Chainable methods for clean, readable code
- ✅ Fully Tested - Comprehensive test coverage with Pest PHP
Requirements
- PHP 8.4 or higher
- Laravel 11.0 or 12.0
Installation
You can install the package via composer:
Publish the config file with:
Configuration
Add your GLS API credentials to your .env file:
The published config file (config/gls-authenticator.php) includes:
Usage
Basic Usage
Get an access token using default configuration:
Token Properties
Multi-Tenant / Runtime Configuration
Perfect for applications serving multiple clients:
Environment Switching
Switch between sandbox and production:
Scope Management
Request specific OAuth scopes:
Fluent API Chaining
Combine multiple configuration options:
Force Fresh Token
Bypass cache and get a fresh token from the API:
Cache Management
Check Configuration
Token Caching
Tokens are automatically cached to minimize API calls:
- Cache Duration: Tokens expire in 4 hours (14,400 seconds)
- Cache TTL: Cached for 3 hours 55 minutes (expires 5 minutes early for safety)
- Multi-Tenant Isolation: Each unique credential set has a separate cache key
- Scope-Specific: Different scopes generate different cache keys
Cache Key Format
Example: gls_auth:sandbox:a3f5c8d2:e9b4f1a6
Error Handling
The package throws specific exceptions for different error scenarios:
Use Cases
Making API Calls
Middleware for Multi-Tenant Apps
Service Class Example
Testing
Run the test suite:
Run static analysis:
Format code with Laravel Pint:
Run all quality checks:
Testing Your Application
Use Laravel's HTTP facade to mock GLS API responses:
API Reference
For detailed API specifications, see the OpenAPI documentation.
Endpoints
- Sandbox:
https://api-sandbox.gls-group.net/oauth2/v2 - Production:
https://api.gls-group.net/oauth2/v2
Token Details
- Grant Type:
client_credentials - Token Type:
Bearer - Validity: 4 hours (14,400 seconds)
- Rate Limit: 100,000 requests per App ID per day
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- SmartDato
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of gls-authenticator with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0