App installation fails even after success response 200

I’m having some trouble with installing a custom app. I tried 2 scenarios

  1. In dev mode. with dev=true, I’m able to establish authentication with my server using OAuth.
  2. Uploaded the same app (fdk pack), without any configuration changes. After authentication, the server returns the 200 status code, but the app is not installed.

Below is a screenshot with the console error, when the custom app is uploaded and tried to install.

In the screenshot, Freshdesk-app in Dev mode is installed successfully. But Freshdesk Local (46455-freshdesk_local), uploaded app, throws some console errors.

Also attaching the server response, just to make sure appropriate code was returned after authentication.

Hi @justin

Welcome to Freshworks Developer Community :tada:

As I can infer, onAppInstall you are making an API call to the server. The server responds with a token that I presume the handler attached to onAppInstall would store before the app is installed successfully. Is my understanding correct? If yes, did you explore OAuth 2.0 that’s possible via the app? Any thoughts about OAuth here just to correct my understanding.

Secondly, when trying the installation as a custom app the server might have logged successfully as it received the requests… I was curious about the browser network. If possible, when this error occurs can you share XHR logs from the browser on this thread?

Please mind removing any sensitive information that comes out of logs.

Do you see onAppInstall simulation successful when the app is simulated locally?

Thanks for the reply @Saif.

onAppInstall,

  1. we authorize the account, make an entry on our side that this account has installed Freshdesk

We are using OAuth 2.0, with the required settings. Dev app also is using the same logic, as I mentioned before.

Attaching network request details for installing the custom app.


Screenshot 2021-11-09 at 5.01.58 PM
Screenshot 2021-11-09 at 5.02.03 PM

After installing the Dev app, Freshdesk requests for an access token to /o/oauth/token (token_url), an access token, refresh token, etc… is returned.

I’m assuming OAuth will/should work the same for Custom App as well as in Dev mode.

One clarification. Will Freshdesk make a request to token_url as soon as the app is authorized?

1 Like

@justin
Good Day!
Seems like the app setup events are failing, that is why the app is not installed,
and as @Saif mentioned, can you please share with us the browser logs/HRA logs to debug further?

and possible please share with us the code snippet of onAppInstal method for our better understanding

Thanks

Just to add on,

Do you mind keeping us aware of the user flow? I am guessing, you are trying to perform OAuth so that app can be used after successful authorization. Am I right?

Good day to you too @Santhosh

Attaching handler on Freshdesk app

On the server side, we aren’t doing much.

  1. After authentication (OAuth 2.0), Freshdesk hits the token_url, and we return the token details.
{
    "token_type": "bearer",
    "access_token": "XXXXXXX",
    "expires_in": 3600,
    "refresh_token": "XXXXXXX"
}
  1. Freshdesk then invokes the onAppInstall handler, and our request looks like the above-attached screenshot.
  2. We verify the incoming request and make a note on our side that this user has enabled Freshdesk
  3. We return 200

That’s it.

In the previous post, I’ve attached the console errors and network details. Let me know if you need anything else.

Hi @justin

I just wanted to confirm another piece…

onAppInstall: function(){

// essential logic

// The PATCH request

renderData(); // [A] Is this method used at the end?

}

See pt. 4 in App Setup Events

Is it possible for you confirm if renderData(); is invoked within server.js's onAppInstall(){..} hander defn?

2 Likes

Thanks a lot @Saif That was the issue. :dancing_women:

2 Likes

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.