PHP code example of josecl / claveunica

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

    

josecl / claveunica example snippets


'claveunica' => [    
  'client_id' => env('CLAVEUNICA_CLIENT_ID'),  
  'client_secret' => env('CLAVEUNICA_CLIENT_SECRET'),  
  'redirect' => env('CLAVEUNICA_REDIRECT_URI') 
],

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ...
        \Josecl\ClaveUnica\ClaveUnicaExtendSocialite::class . '@handle',
    ],
];

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

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

    dump($claveUnicaUser->run);
    dump($claveUnicaUser->dv);
    dump($claveUnicaUser->first_name);
    dump($claveUnicaUser->last_name);

'claveunica' => [    
  'client_id' => env('CLAVEUNICA_CLIENT_ID'),  
  'client_secret' => env('CLAVEUNICA_CLIENT_SECRET'),  
  'redirect' => env('CLAVEUNICA_REDIRECT_URI') 
  // Configura servicio alternativo a ClaveÚnica
  'auth_uri' => env('CLAVEUNICA_AUTH_URI', 'https://accounts.claveunica.gob.cl/openid/authorize'),
  'token_uri' => env('CLAVEUNICA_TOKEN_URI', 'https://accounts.claveunica.gob.cl/openid/token'),
  'user_uri' => env('CLAVEUNICA_USER_URI', 'https://www.claveunica.gob.cl/openid/userinfo'),
],