PHP code example of socialiteproviders / duo

1. Go to this page and download the library: Download socialiteproviders/duo 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/ */

    

socialiteproviders / duo example snippets


'duo' => [
    'client_id' => env('DUO_CLIENT_ID'),
    'client_secret' => env('DUO_CLIENT_SECRET'),
    'redirect' => env('DUO_REDIRECT_URI'),
    'domain' => env('DUO_DOMAIN'), // Custom Duo SSO subdomain
],

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

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

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

use Laravel\Socialite\Facades\Socialite;

Route::get('/auth/duo/callback', function () {
    $user = Socialite::driver('duo')->user();

    // $user->token
    // $user->id
    // $user->name
    // $user->email
});

return Socialite::driver('duo')
    ->scopes(['openid', 'profile', 'email', 'groups'])
    ->redirect();

Route::get('/auth/duo/callback', function (): void {
    $user = Socialite::driver('duo')->user();

    dd($user->getRaw());
});