Skip to content

Instantly share code, notes, and snippets.

@sbkinney
Created November 12, 2012 23:40
Show Gist options
  • Save sbkinney/4062834 to your computer and use it in GitHub Desktop.
Save sbkinney/4062834 to your computer and use it in GitHub Desktop.
Example PHP script for SSO for Zendesk
<?
/*
* Remote authentication stub for PHP
*
* This is meant as a template for your own customization. You can identify the user anyway you like,
* integrate it into your intranet, web app or similar.
*
* You may call this script directly or have Zendesk redirect to it using the
* Remote Authentication URL.
*
*/
/* The following values should be set from your source of information */
$sFullName = "Name";
$sEmail = "[email protected]";
$sExternalID = "";
$sOrganization = "";
$sTags = "";
$sRemotePhotoURL = "";
$sReturnTo = "";
/* Insert the Autentication Token here */
$sToken = "";
/* Insert your account prefix here. If your account is yoursite.zendesk.com: */
$sUrlPrefix = "yoursite";
/* Build the message */
$sTimestamp = isset($_GET['timestamp']) ? $_GET['timestamp'] : time();
$sMessage = $sFullName."|".$sEmail."|".$sExternalID."|".$sOrganization."|".$sTags."|".$sRemotePhotoURL."|".$sToken."|".$sTimestamp;
$sHash = MD5($sMessage);
$sso_url = "https://".$sUrlPrefix.".zendesk.com/access/remoteauth/?name=".$sFullName."&email=".$sEmail."&external_id=".$sExternalID."&timestamp=".$sTimestamp."&hash=".$sHash."&return_to=".$sReturnTo;
header("Location: ".$sso_url);
?>
@ChrisCinelli
Copy link

You forgot to add the organization parameter n the sso_url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment