Handshake Authentication

1. Add varo auth to your site

<script type="text/javascript" src="https://auth.varo.domains/v1"></script>

2. Load the varo class

var varo = new Varo();

3. Call the auth method

varo.auth().then(auth => {
	if (auth.success) {
		// handle success by calling your api to update the users session
		$.post("/auth", JSON.stringify(auth.data), (response) => {
			window.location.reload();
		});
	}
});

Auth response example

{
	"data": {
		"request": "00000000000000000000000000000000",
		"id": "11111111111111111111111111111111",
		"name": "varo"
	},
	"success": true
}

Example api for your sessions

<?php
	session_start();
	//  ^ make sure to add this line to all pages of your site

	$json = file_get_contents("php://input");
	$data = json_decode($json, true);

	$verify = file_get_contents("https://auth.varo.domains/verify/".$data["request"]);
	$decoded = @json_decode($verify, true)["data"];
	if (@$decoded["name"]) {
		$_SESSION["name"] = $decoded["name"];
	}
?>