FreshDesk SSO using JWT with C#

Paul Wheeler
1 min readMay 20, 2021

--

FreshDesk has recently moved to a newer SSO system through FreshWorks and I couldn’t find a decent example online in C#. We are allowing users to access FreshDesk by clicking on a support link within our web application. It took a bit of time to figure out how to get this working with the new system so I thought I would post an example of how I got it working here to maybe help someone else. (This is their relevant support document: https://support.freshworks.com/support/solutions/articles/50000000670)

When a user in our application clicks on the support link, we initially send them to this URL (replace {subdomain} with whatever subdomain is configured for your company : https://{subdomain}.freshdesk.com/customer/login

If the user is not already logged in, and you only have JWT setup as the SSO option, they will be redirected back to your site at whatever URL you configured. You will need to retrieve the “state” and “nonce” values from the query string which should look something like this (from their docs):
https://awesomecompany.com/sso/jwt/login?client_id=a13v13&state=hgdg43567&nonce=1545894408&grant_type=implicit&scope=profile+openid+email

You can then generate the token using the code below, and redirect the user to the URL and they will be automatically signed in. I am using the JWT Nuget package since has a nice simple interface to do what we need (https://www.nuget.org/packages/JWT/).

--

--

Paul Wheeler
Paul Wheeler

No responses yet