Skip to content

Instantly share code, notes, and snippets.

@darkpssngr
darkpssngr / sso_login_freshdesk.cs
Last active August 25, 2021 09:03 — forked from barryokane/sso_login_freshdesk.cs
SSO Login for Freshdesk support portal - ASP.Net C# Sample Code
static string GetSsoUrl(string baseUrl, string secret, string name, string email) {
var timems = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds.ToString();
return String.Format("{0}/login/sso?name={1}&email={2}&timestamp={3}&hash={4}",
baseUrl, Server.UrlEncode(name), Server.UrlEncode(email), timems, GetHash(secret, name, email, timems));
}
private static string GetHash(string secret, string name, string email, string timems) {
var input = name + secret + email + timems;
var keybytes = Encoding.UTF8.GetBytes(secret);
var inputBytes = Encoding.UTF8.GetBytes(input);