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',
],
];
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
}
}