mnastalski / allegro-socialite
Allegro OAuth2 Provider for Laravel Socialite
v1.0.0
2022-05-24 20:48 UTC
Requires
- php: >=7.4
- ext-json: *
- illuminate/support: >=6.0
- laravel/socialite: ^5.0
This package is auto-updated.
Last update: 2024-11-27 02:01:41 UTC
README
Allegro OAuth2 Provider for Laravel Socialite.
Requirements
- PHP >=7.4
Installation
composer require mnastalski/allegro-socialite
Usage
Add configuration to config/services.php
'allegro' => [ 'client_id' => env('ALLEGRO_CLIENT_ID'), 'client_secret' => env('ALLEGRO_CLIENT_SECRET'), 'redirect' => env('ALLEGRO_REDIRECT'), ],
To make sandbox mode configurable you can add the following to the above configuration:
'sandbox' => env('ALLEGRO_SANDBOX', false),
Example usage:
use Laravel\Socialite\Facades\Socialite; $provider = Socialite::driver('allegro'); $provider->redirect(); $provider->user(); $provider->getAccessToken();
For $provider->user()
to work the allegro:api:profile:read
permission must be granted.
Refreshing the access token:
Socialite::driver('allegro')->getRefreshTokenResponse($refreshToken);
Example response:
[ 'access_token' => '...', 'token_type' => 'bearer', 'refresh_token' => '...', 'expires_in' => 43199, 'scope' => 'allegro:api:profile:read', 'allegro_api' => true, 'jti' => '...', ]