Skip to content

gradus0/appleAuth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

appleAuth

Sign in with Apple (apple JWS token)

steps:

example run code:

<?php
include_once "appleAuth.class.php";

// https://developer.apple.com/account/resources/identifiers/list/serviceId -- indificator value
$clientId = ""; // com.youdomen
// your developer account id -> https://developer.apple.com/account/#/membership/
$teamId = "";
// key value show in -> https://developer.apple.com/account/resources/authkeys/list
$key = "";
// your page url where this script
$redirect_uri = ""; // example: youdomen.com/appleAuth.class.php
// path your key file, download file this -> https://developer.apple.com/account/resources/authkeys/list
$keyPath =''; // example: ./AuthKey_key.p8


try{

	$appleAuthObj = new \appleAuth\sign($clientId,$teamId,$key,$redirect_uri,$keyPath);

	if(isset($_REQUEST['code'])){
		$jwt_token = $appleAuthObj->get_jwt_token($_REQUEST['code']);
		$response = $appleAuthObj->get_response($_REQUEST['code'],$jwt_token);
		$result_token = $appleAuthObj->read_id_token($response['id_token']);

		var_dump($response);
		var_dump($result_token);
	}else{

		$state = bin2hex(random_bytes(5));

		echo "<a href='".$appleAuthObj->get_url($state)."'>sign</a>";
	}

} catch (\Exception $e) {
	echo "error: ".$e->getMessage();
}

About

Sign in with Apple (apple JWS token)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages