PHP code example of sempro / socialite-provider-vipps

1. Go to this page and download the library: Download sempro/socialite-provider-vipps library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sempro / socialite-provider-vipps example snippets


Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
    $event->extendSocialite('vipps', \Indent\SocialiteProviderVipps\Provider::class);
});

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        \Indent\SocialiteProviderVipps\VippsExtendSocialite::class . '@handle',
    ],
];

'vipps' => [
    'client_id' => env('VIPPS_CLIENT_ID'),
    'client_secret' => env('VIPPS_CLIENT_SECRET'),
    'redirect' => env('VIPPS_REDIRECT_URI'),
    
    // Optional. Can be provided for interacting with vipps test api.
    'base_url' => 'apitest.vipps.no',
    
    // Optional. Can be added in order to request more data.
    // (See link for list of scopes: https://api.vipps.no/access-management-1.0/access/.well-known/openid-configuration)
    'scopes' => [
        'name',
        'email',
    ],
],

return Socialite::driver('vipps')->redirect();

$user = Socialite::driver('vipps')->user();


 
 namespace App\Http\Controllers;
 
 use App\Http\Controllers\Controller;
 use Illuminate\Http\RedirectResponse;
 use Laravel\Socialite\Facades\Socialite;
 
 class VippsAuthController extends Controller
 {
     public function redirect(): RedirectResponse
     {
         return Socialite::driver('vipps')->redirect();
     }
 
     public function callback()
     {
         $user = Socialite::driver('vipps')->user();
 
         if (!$user) {
             // Return error message
         }

         // Verify user exists, authenticate and redirect
     }
}