Freshchat app works using SDK Test environment but not in production

I have created an application that sends an api request to get logged in agent data, as well as conversation data. I make these api requests using the API _Token generated from freshchat to hit the freshchat API.

When I test the app using the SDK, with installing the API_Token in the iparams.json installation screen, it works without issues.

However, once I install the application, and apply the same API_Token at installation into the production environment, I am getting an JWT error in the response to the API Request.

This is the error I get:

the full error is: “{“success”:false,“error_code”:0,“error_message”:“JWT strings must contain exactly 2 period characters. Found: 1”}”

Not sure why this is happening and was hoping for a little insight.

I have refactored the code to better handle the errors. Below is a code snippet of what I am trying to do when I get the JWT Error.

 // Get loggedInAgent to verify as Administrator"loggedInAgent").then(
        (data) => {
          let loggedInAgent =;

          // Make API call with agent id to obtain Agent Role
          let headers = {
            Accept: "application/json",
            Authorization: "Bearer <%= (iparam.apiKey) %>",
            "Content-type": "application/json",
          const options = {
            headers: headers,
          let url = "" + loggedInAgent;
            .get(url, options)
            .then((data) => {
              let responseBody = data.response;
              let obj = JSON.parse(responseBody);

              let agentRole = obj.role_id;

              if (agentRole === "ACCOUNT_ADMIN") {
            .catch((error) => {
              client.interface.trigger("showNotify", {
                type: "danger",
                message: "Unable to retrieve agent role",
              console.log("Exception - ", error);
        (error) => {
          console.log("Exception - ", error);

I have tried changing the Authorization to Authorization: "Basic <%= encode(iparam.apiKey) %>" or Authorization: "Bearer <%= encode(iparam.apiKey) %>" but those return an error regarding improper authorization header.

Again, when I run fdk run navigate to apps > custom apps, I can see the application with “in dev” next to the app. I click install and then enter the API Token from freshchat admin settings. Go to a conversation and then append ?dev=true to the end of the url, reload and the app runs without issues.

But, when I package the app and upload to the developer portal, then install the app from the app gallery, load a conversation in production, I get the JWT Error mentioned above.

Any help would be greatly appreciated. I have spent a while trying to debug this.

Thank you!

Hi Zachary,
Thank you for the detailed information. We are able to reproduce this issue. We are actively working on fixing this issue. We will keep you posted.


Hi @Zach,
Can you please try the below code ( removed brackets around iparam.apiKey )and let us know if it worked.

 Authorization: "Bearer <%= iparam.apiKey %>"
1 Like

Hi @ManiDeepak_Vandrangi,

Brilliant!!! Removing the braces around iparam.apiKey fixed the issue. Was not aware that would cause a problem. Thank you for your help!