happyonlinegr / socialite-provider-vipps
Vipps Provider for Laravel Socialite
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/happyonlinegr/socialite-provider-vipps
Requires
This package is not auto-updated.
Last update: 2025-10-17 16:38:43 UTC
README
Installation
composer require happyonlinegr/socialite-provider-vipps
Service Provider
Add to app.php
:
'providers' => [ Laravel\Socialite\SocialiteServiceProvider::class, \SocialiteProviders\Manager\ServiceProvider::class, ];
Event Listener
- Add
SocialiteProviders\Manager\SocialiteWasCalled
event to yourlisten[]
array inapp/Providers/EventServiceProvider
.
Example:
/** * The event handler mappings for the application. * * @var array */ protected $listen = [ \SocialiteProviders\Manager\SocialiteWasCalled::class => [ '\SocialiteProviders\Vipps\VippsExtendSocialite@handle', ], ];
Configuration setup
You will need to add an entry to the services configuration file so that after config files are cached for usage in production environment (Laravel command artisan config:cache
) all config is still available.
Add to config/services.php
.
'vipps' => [ 'client_id' => env('VIPPS_CLIENT_ID'), 'client_secret' => env('VIPPS_CLIENT_SECRET'), 'redirect' => env('VIPPS_REDIRECT_URI'), ],
Remember to whitelist the redirect_uri in the Vipps portal.
5. Usage
To initiate the Vipps login, add this to your controller
return Socialite::driver('vipps')->redirect();
You've now gotten a user token from Vipps in your callback function. Now we need to use the user token to get the phone number of the authenticated user.
$user = Socialite::driver('vipps')->stateless()->user();
Example for a VippsAuthController:
<?php namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Laravel\Socialite\Facades\Socialite; class VippsAuthController extends Controller { public function index(Request $request) { return Socialite::driver('vipps')->redirect(); } public function handleCallback() { $user = Socialite::driver('vipps')->stateless()->user(); if (!$user) { //Return error message } //Do stuff } }