ngekoding / google-login
Login with Google
v1.0.0
2022-08-28 14:14 UTC
Requires
- php: >=5.6
- google/apiclient: ^2.12
This package is auto-updated.
Last update: 2024-04-28 18:10:21 UTC
README
Simplifying the Google Login in a PHP application.
Requirements
- PHP 5.6 or above
- The OAuth client ID from Google Cloud Console
Installation
composer require ngekoding/google-login
Usage
Just call the auth
method and you are done!
<?php // Include the autoload require_once 'vendor/autoload.php'; // Prepare the configs $clientId = '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(); }