Tollbridge.co service provider for Laravel Socialite authentication.
tollbridge/laravel-socialite is a Laravel package for tollbridge.co service provider for laravel socialite authentication..
It currently has 0 GitHub stars and 13 downloads on Packagist (latest version v1.0.1).
Install it with composer require tollbridge/laravel-socialite.
Discover more Laravel packages by tollbridge
or browse all Laravel packages to compare alternatives.
Last updated
Tollbridge is a user-authentication, subscription and paywall software as a service. This package will help you to implement Tollbridge's based authentication in your Laravel application in just a few minutes.
Install via composer
composer require tollbridge/laravel-socialite
To access your Tollbridge credentials, visit the Integrations section in the Tollbridge admin. Add the provided credentials on the Tollbridge platform to your .env file:
TOLLBRIDGE_APP_ID=
TOLLBRIDGE_CLIENT_ID=
TOLLBRIDGE_CLIENT_SECRET=
In the Tollbridge Integrations section, you will need to set the Callback URL to match the correct path in your application. By default this URL will be your full protocol/hostname along with the path /tollbridge/callback. Note that this callback path is fully configurable within the tollbridge config file.
url(config('tollbridge.routing.callback')) e.g. https://www.example.test/tollbridge/callback
You can publish the configuration file to the local project directory using artisan:
php artisan vendor:publish --tag=tollbridge-config
This is the content of the config file:
<?php
return [
'app_id' => env('TOLLBRIDGE_APP_ID'),
'client_id' => env('TOLLBRIDGE_CLIENT_ID'),
'client_secret' => env('TOLLBRIDGE_CLIENT_SECRET'),
'routing' => [
'login' => '/tollbridge/login',
'logout' => '/tollbridge/logout',
'callback' => '/tollbridge/callback',
],
];
After install, just add the authentication routes to /routes/web.php
Route::get(config('tollbridge.routing.login'), function () {
//session()->set('url.intended', request()->input('url'));
//..
return Socialite::driver('tollbridge')->redirect();
});
Route::get(config('tollbridge.routing.logout'), function () {
//session()->flush();
//..
return redirect()->intended();
});
Route::get(config('tollbridge.routing.callback'), function () {
$user = Socialite::driver('tollbridge')->user();
//session()->put('user', $user);
//$user = Socialite::driver('tollbridge')->userFromToken($user->token);
//$user->getName();
//$user->getEmail();
//$user->getPlan();
//..
return redirect()->intended();
});
To start the authentication process, add a link to the login URL:
<a href="{{ url(config('tollbridge.routing.login')) }}">Login</a>
The Tollbridge\Socialite\Middleware\TollbridgeRedirects middleware is automatically loaded.
If the param _tollbridge_logout is set the user will get redirected to config('tollbridge.routing.logout')
If the param _tollbridge_reauth is set the user will get redirected to config('tollbridge.routing.login').
This will in turn re-initiate an OAuth session.
First link up your local repository:
composer config repositories.local '{"type": "path", "url": "../tollbridge-laravel-socialite"}' --file composer.json
Then install as normal via composer:
composer require tollbridge/laravel-socialite