PHP code example of ngekoding / google-login

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

    

ngekoding / google-login example snippets



// Include the autoload
ntId = 'YOUR CLIENT ID';
$clientSecret = 'YOUR CLIENT SECRET';
$redirectUri = 'YOUR REDIRECT URI'; // The URL to this file/endpoint

$googleLogin = new \Ngekoding\GoogleLogin\GoogleLogin($clientId, $clientSecret, $redirectUri);

try {
    $googleLogin->auth();
    
    header('Content-Type: application/json');
    echo json_encode($googleLogin->user());
} catch (\Exception $e) {
    echo 'Error: '.$e->getMessage();
}