PHP code example of gooby / ez-auth-client

1. Go to this page and download the library: Download gooby/ez-auth-client 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/ */

    

gooby / ez-auth-client example snippets




$auth = new Gooby\EzAuthClient\Auth();
$user = $auth->getUserOrLogin();

echo "You're logged in and your ID is {$user->id}";


use Gooby\EzAuthClient\Auth;
use Gooby\EzAuthClient\JwtDecodeException;

$client = new Auth();

try {

    $user = $client->getUser();

} catch (JwtDecodeException $e) {

    // Invalid token, or bad secret
    MyApp::logFailedLoginAttempt('Invalid Token: ' . $e->getMessage());

    // Redirect request to login page
    $client->login();