Skip to content

Enable Single Sign On with JSON Web Token (JWT)

Views
28961
Last updated

A JSON Web Token (JWT) is an open standard that defines a compact and self-contained way of transmitting information between two parties as a JSON object.

Using JWT integration with HappyFox, you can build your own login portal or reuse an existing login portal for providing access to HappyFox support center. This way, your contacts do not need separate credentials to view their existing tickets or raise new tickets.

You can find more information about JWT here 🔖.

Applicable Plans: ✖️ Mighty ✔️ Fantastic ✔️ Enterprise ✔️ Enterprise Plus

Installing the JWT App in HappyFox:

Setting up JWT integration in HappyFox

Enter the following details, 

 

Generate the <token_string> using a JSON payload. A sample has been provided as follows:

{
  "name": "John Doe",
  "iat": 1717740457,
  "email" : "[email protected]",
  "jti" : "2c65fe8c-2494-11ef-9bc0-1e00e222b599"
}

The fields iat and jti are required fields

iat - Stands for issued at. This is a JWT standard formatted string that represents the time at which the token was generated. The sample provided above has been generated using int(time.time()) in python.

jti - This is a unique identifier for each request. The value 2c65fe8c-2494-11ef-9bc0-1e00e222b599 in the sample has been generated using str(uuid.uuid1()) in python.

 

 

To redirect users to their ticket list, home page and knowledge base use the return_to url parameter.

 

Home page: https://acme.happyfox.com/jwt/?token={JWT_Token_String}&return_to=/home

Ticket list: https://acme.happyfox.com/jwt/?token={JWT_Token_String}&return_to=/tickets

KB: Ticket list: https://acme.happyfox.com/jwt/?token={JWT_Token_String}&return_to=/kb

 

Once the feature is enabled, the login link in your Support Centre will redirect the user to the Remote Login URL specified above. Similarly, when the user logs out, they will be redirected to the Remote Logout URL.

Note: Make sure you set the Integration Status as "Active". in JWT Settings Section.

Setting up your JWT implementation:

To authenticate a user, you need to send the following values to HappyFox as part of your JWT request. Please learn more about how to make a valid JWT request from jwt.io

These values need to be encoded with the HS256 algorithm with the Secret Key that you get from the JWT integrations page in your HappyFox account as mentioned above. Once the payload is encoded, redirect the user to https://<accountname>.happyfox.com/jwt/?token=<payload>

Once HappyFox validates the payload, it will log the user into the Support Centre with the specified name/email. 

Warning ⚠️: The JWT token is valid for 120 seconds from HappyFox side. If the redirect from the customer application takes longer than this, for some reason, an error like this will be seen - "Remote token has expired"

Tags