Yes, @rohan15.
Platform it self will refresh the access_token with the help of referesh token.
Summary for this thread followers
Rohan is trying to implement a OAuth mechanism with a 3rd OAuth service. On the way he discovered that he doesn’t have to implement OAuth exchange himself but freshworks platform provides OAuth 2 capabilities.
access_token
sent by 3rd party provider.accessToken
instead of access_token
as per official standard response structure.Rohan is trying to find a workaround to solve this problem. One of the options to consider is to use a Middleware that can translate to the standard response structure for our platform begin OAuth cycle.
Hi Saif/Team,
With reference to our last post, the third party is trying to we will provide a new oAuth endpoint with below request/response.
Could you please help to confirm the same today, so that we can ask them to go ahead?
{
“status”: “approved”,
“access_token”: “Cd0Vh5g44IuRqBGdrrOh0”,
“refresh_token”: “muFpsulLCzAB4HyfnYwAIfroN”,
“expires_in”: “2399”,
“scope”: “”,
“token_type”: “BearerToken”
}
Request will be same like before:
POST /oauth/v1/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
grant_type=authorization_code&client_id=SpxYtZAMgUfD1XjTmHmZ1yzZf91xuKp8&client_secret=NyzsTWj5lHXctxwz&code=xhFSO5kM
Hi Saif/Team,
The third party had deployed the Oauth endpoint with the RFC protocol standards. We tested it and our serverless app is now able to do the Oauth2 authentication and get the access_token for calling the SMS API.
Could you please help to clarify the below 3 points as well:
Yesterday night we had initiated the request and access_token was generated. Today when we hit the request for the first time, we got “Token Expired” from third party. It was only after we deleted the .fdk file , the access_token got replaced. Will we need to delete .fdk folder everytime in FD test environment? When we deploy in FD production , how will this run ? Will it be handled automatically or manual intervention be required? As per the last document shared, the authorization_code from url redirection is for 1 time use only.
Secondly, after token is being substituted, and Third Party API is being called, the SMS is being sent as expected by third party. Third party is returning JSON response body as well , however what we can understand from below logs is that at FD side it’s being treated as an error response because it can’t find “Application/json” (A capital). Any workaround for this at FD side to show it as SUCCESS?
FDK 3468: (proxy.js) Proxy came back with error as null, body as {“id”:“631021001”,“type”:“TEXT”,“status”:“SUCCESS”,“sentTime”:“2020-05-15T12:55:56+06
:30”,“content”:
FDK 3468: (proxy.js) Looking for “Application/json” in application/json,application/xml,text/html,text/xml,application/jsonp,text/plain,application/ja
vascript,application/vnd.api+json
error { status: 415,
headers: {},
response: ‘Unsupported content type’,
errorSource: ‘APP’,
attempts: 1 }
FDK 3468: (coverage-util.js) Writing coverage.
Do you have any concept in FD serverless app for an external property file that can be updated on runtime? Basically we would like to keep the SMS texts in a property file such that the text can be changed whenever required without redeploying the application.
Hi Saif, Team,
Would like to add 1 more question in addition to the above 3:
Currently this servless app is being invoked onTicket creation event only. If we want this single serverless app to be invoked onTicketCreation, onTicketClose and onTicketUpdate events how would we need to modify our server.js so that it can be invoked on all 3 events. Could you please provide some samples for the same?
Hello @rohan15,
Hi Saif/Team,
Please find below comments:
You can do same function declaration and definition out the exports block and make a function call inside the any product event that you want. I hope that should help you solve the problem.
Thanks Saif/Team.
We will check the above information and try to implement the same.
Could you guys also let us know that in the PAYLOAD for onTicketCreation and OnTicketClose, which parameters do we refer to for getting the ticket id number ,ticket creation date and expected resolution date? Actually, we need to send this information in our SMS.
Hi Team,
Please help to provide the above details regarding ticket details from onTicketCreate and onTicketClose payload. Thanks
Thanks Hemchander for the information.
Hi Saif/Team,
Could you please check with platform engineers today on the below point and let us know the update?
If they could include the header mentioned?
Yes, I’ve checked with the team. Unfortunately, we won’t be able to makes changes on our platform. The solution goes as discussed before to write a middleware or changes within 3rd party response following RFC standards.
Ok Saif, we will need to discuss with our team once regarding this.
Need some more info:
Hi Team,
In addition to the above queries. Please help with the below:
We deployed the app as a custom app in production. Created a ticket on the portal but SMS was not sent although it was working in production. Status is also shown as internally published. Please let me know where I can find the logs on the FD account portal in production and if anything else is needed to be done to run in production?
Hey @rohan15,
Hi Saif/Team,
We were able to deploy the app in production and SMS is also going on ticket creation and closure. However, we are observing that once authentication token is getting expired , after say 1 hour, we are getting token expired error while calling the SMS API as it seems the token was not refreshed. Only after we go to custom apps and click on reauthorize, the SMS API is accessible again.
Can you guys please help us to debug this, as we are not seeing any detailed errors in the logs on production. This token refresh should happen automatically as discussed earlier.
Hi Rohan,
Do you happen to see any errors when you try to run the app locally? After 1 hr?
Also, I’d direct message you to collect you App ID, Account ID and the time when you saw this issue to find out what error is being seen.