Skip to content

Latest commit

 

History

History
33 lines (28 loc) · 822 Bytes

README.md

File metadata and controls

33 lines (28 loc) · 822 Bytes

Google Sign In (PHP Backend)

Authenticate a Google Sign In token on the backend with PHP. The authenticator will validate the user's Google ID Token.

Install

$ php bin/composer install

Usage

Make an HTTPS Post request to data/example.php and pass a Google Sign In token as token

var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://yourbackend.example.com/data/example.php');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
  console.log(JSON.parse(xhr.responseText));
};
xhr.send('token=' + id_token);

Returns

The authenticator will return your content, or a JSON object on error / failure

On error / failure, the JSON object will look like so:

{
  "status": false,
  "body": "<Error description>"
}