PHP code example of barnabynorman / google-auth-wrapper

1. Go to this page and download the library: Download barnabynorman/google-auth-wrapper 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/ */

    

barnabynorman / google-auth-wrapper example snippets



his is your landing place
$redirectUrl = 'https://research.familynorman.org.uk';

$clientId = 'your google client ID';
$clientSecret = 'your google client Secret';

$auth = new GoogleAuthWrapper($clientId, $clientSecret, $redirectUrl);

$authResponse = $auth->doLogin();

if (is_array($authResponse)) {
    // Redirect response as part of login processs
	header('Location: ' . $authResponse['redirect']);

} elseif ($authResponse !== false) {
    // Authenticated with google

    // Test the email address
    switch ($authResponse) {
        case '[email protected]':
        // Content here
        break;

        case '[email protected]':
        // Content here
        break;

        case '[email protected]':
        // Content here
        break;

        case '[email protected]':
        // Content here
        break;

        default:
        // Show login page or 404 etc
    }
}