Last active
November 22, 2022 23:26
-
-
Save thanashyam/1662527 to your computer and use it in GitHub Desktop.
SSO Login for Freshdesk support portal - PHP Sample Code (Updated)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('FRESHDESK_SHARED_SECRET','____Place your Single Sign On Shared Secret here_____'); | |
define('FRESHDESK_BASE_URL','http://{{your-account}}.freshdesk.com/'); //With Trailing slashes | |
function getSSOUrl($strName, $strEmail) { | |
$timestamp = time(); | |
$to_be_hashed = $strName . FRESHDESK_SHARED_SECRET . $strEmail . $timestamp; | |
$hash = hash_hmac('md5', $to_be_hashed, FRESHDESK_SHARED_SECRET); | |
return FRESHDESK_BASE_URL."login/sso/?name=".urlencode($strName)."&email=".urlencode($strEmail)."×tamp=".$timestamp."&hash=".$hash; | |
} | |
header("Location: ".getSSOUrl("User's Name","[email protected]")); | |
// This is not deprecated by Freshdesk. Simple SSO is not supported |
Its works
An easier to read code with the help of PHP's http_build_query
:
http_build_query([
'name' => $strName,
'email' => $strEmail,
'timestamp' => $timestamp,
'hash' => hash_hmac('md5', $str_to_be_hashed, FRESHDESK_SHARED_SECRET),
], '', '&');
The whole code is in this fork:
https://gist.github.com/AlLoud/cfdea1aac2d158f288deaa71ed186037
How do you guys handle a user's email address change scenario?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in Python
http://www.abhiy.com/single-sign-on-remote-authentication-in-freshdesk-by-python/
Here in python