PHP code example of wotz / socialite-zenith

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

    

wotz / socialite-zenith example snippets


'zenith' => [
    'base_url' => env('ZENITH_URL'),
    'client_id' => env('ZENITH_CLIENT_ID'),
    'client_secret' => env('ZENITH_CLIENT_SECRET'),
    'redirect' => env('ZENITH_REDIRECT_URI'),
],

use Laravel\Socialite\Facades\Socialite;

Route::get('/auth/zenith/redirect', fn () => Socialite::driver('zenith')->redirect());

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

    $zenithUser->getId();    // Zenith user id, as a string
    $zenithUser->getName();  // "firstname lastname"
    $zenithUser->getEmail();
    $zenithUser->getRaw();   // the full `data` object from /api/user/current
});

use Illuminate\Http\Client\RequestException;

try {
    $zenithUser = Socialite::driver('zenith')->user();
} catch (RequestException $exception) {
    if ($exception->response->forbidden()) {
        // deactivated in Zenith
    }
}