PHP code example of digitive / vipps-socialite-provider

1. Go to this page and download the library: Download digitive/vipps-socialite-provider 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/ */

    

digitive / vipps-socialite-provider example snippets


/**
 * The event handler mappings for the application.
 *
 * @var array
 */
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        '\SocialiteProviders\Vipps\VippsExtendSocialite@handle',
    ],
];

'vipps' => [
    'client_id' => env('VIPPS_CLIENT_ID'),
    'client_secret' => env('VIPPS_CLIENT_SECRET'),
    'redirect' => env('VIPPS_REDIRECT_URI'),
],

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

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


 
 namespace App\Http\Controllers\Api;
 
 use App\Http\Controllers\Controller;
 use Illuminate\Http\Request;
 use Laravel\Socialite\Facades\Socialite;
 
 class VippsAuthController extends Controller
 {
     // User clicked Login in with Vipps button
     public function index(Request $request)
     {
         return Socialite::driver('vipps')->redirect();
     }
 
     // Vipps callback function (VIPPS_REDIRECT_URL in .env)
     public function handleCallback()
     {
         $user = Socialite::driver('vipps')->stateless()->user();
 
         if (!$user) {
             //Handle errors for missing user
         }

         //Authenticate user
     }
}

Socialite::driver('vipps')->redirectUrl($redirectUrl)->redirect();

Socialite::diver('vipps')->scopes(['openid', 'api_version_2', 'phoneNumber', 'name'])->redirect();
 php
'providers' => [
    Laravel\Socialite\SocialiteServiceProvider::class,
    \SocialiteProviders\Manager\ServiceProvider::class,
];