49
verifyidtoken
verifyidtoken
SYNOPSIS
verifyidtoken($credential, $client_id=false)
DESCRIPTION
verifyidtoken verifies the Google ID token $credential for the OAuth client $client_id and returns its payload.
If the token is invalid or cannot be verified, verifyidtoken returns false.
CODE
- require_once 'vendor/autoload.php';
- function verifyidtoken($credential, $client_id=false) {
- try {
- $client = new Google_Client(['client_id' => $client_id]);
- return $client->verifyIdToken($credential);
- }
- catch(Exception $e) {
- }
- return false;
- }
Comments