public static async Task <string> GetJWTToken(string APISecret, JWT_Payload payload)
        {
            JwtEncoder jwt = new JwtEncoder(new HMACSHA256Algorithm(), new JsonNetSerializer(),
                                            new JwtBase64UrlEncoder());

            string requestToken = jwt.Encode(payload, APISecret);

#if DEBUG_MESSAGES
            Console.WriteLine($"Getting JWT Auth token for payload:");
            Console.WriteLine($"{JsonConvert.SerializeObject(payload, Formatting.Indented)}");
            Console.WriteLine($"With request token: {requestToken}");
#endif
            HttpWebResponse response = await SendWebRequest(HttpMethod.Post, TWP_API_UTILS.AUTH_SERVICE_ENDPOINT, requestToken, null);

            if (response.StatusCode == HttpStatusCode.Created)
            {
                JObject result = null;

                using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                {
                    string responseString = await sr.ReadToEndAsync();

                    result = JObject.Parse(responseString);

                    string authToken = result["token"].ToString();

                    return(authToken);
                }
            }

            throw new InvalidOperationException($"Received an error while requesting a JWT token: " +
                                                $"{response.StatusCode} - {response.StatusDescription}");
        }
        public static async Task <string> GetSSOLink(string apiSecret, int partnerId, int siteId, string apiToken, APIProduct ssoType, string ssoUserIdentifier)
        {
            JWT_Payload ssoPayload = new JWT_Payload(partnerId, siteId, ssoType)
            {
                User = new JWT_UserInfo(ssoUserIdentifier)
            };

            string ssoUrl = TWP_API_UTILS.BASE_EMPLOYEE_SSO_ENDPOINT;

            if (ssoType == APIProduct.TWP_Supervisor_SSO)
            {
                ssoUrl = TWP_API_UTILS.BASE_SUPERVISOR_SSO_ENDPOINT;
                ssoPayload.User.Type = JWT_Payload.JWT_SUPERVISOR_TYPE_ID;
            }

            return(ssoUrl + await GetJWTToken(apiSecret, ssoPayload));
        }