Handshake Authentication

1. Add ShakeStation Auth to your site

<script type="text/javascript" src="https://auth.shakestation.io/v1"></script>

2. Load the ShakeStation class

var ss = new ShakeStation();

3. Call the auth method

ss.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": "shakestation"
	},
	"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.shakestation.io/verify/".$data["request"]);
	$decoded = @json_decode($verify, true)["data"];
	if (@$decoded["name"]) {
		$_SESSION["name"] = $decoded["name"];
	}
?>