Skip to main content


We are developing an OAuth-enabled plugin and experiencing the following problem:
- oauth-config.yml is configured properly and authorization is being passed successfully



- "localstore" file is created and contains a valid "access_token"



- whitelisted-domains are configured in manifest.yml



- app.js contains the example code from https://developers.freshdesk.com/docs/oauth/






but
- when testing locally there appears an "oauth not defined" message in console



- in app.js get() method for the $request leads to the 400 Bad Request








requestinfo_26438.png


Hi Alex,






You can ignore the "oauth not defined" message, it is a warning and the code will proceed with no impact. Not sure on 400 Bad request, can you please share the get() portion of the code?






Thanks



Mahesh






Thank you for your reply Maheshst.

It is roughly the example you have in the sample app:



    var headers = {"Authorization": "Bearer <%= access_token %>"};
var options = {
headers: headers,
isOAuth: true
};

this.$request.get("<third-party api>", options)
.done(function(data) {
console.log("Success!");
})
.fail(function(err) {
console.log(err);
});
}


getrequest_26464.png


Hi Alex,






Can you try frsh command in verbose mode and check






$ frsh -v run






Please share the logs we can check






Thanks



Mahesh


















Hi Alex,






Also check https://developers.freshdesk.com/docs/request-api/#local_testingthe page shows a shield icon to allow ur browser to access http link.






Please check if u follow this step 






Thanks



Mahesh






Hi Mahesh,

Also check https://developers.freshdesk.com/docs/request-api/#local_testing , the page shows a shield icon to allow ur browser to access http link.
Yes, I've followed that step and allowed scripts loading.



The output in verbose mode:
1. details of the app request to a Freshdesk portal's ticket (ticket and current user properties)
2. details of the app response with the html/css data (from template.html and style.scss)



3. "<script>" part with the same text as in app.js



4. no mentions about the get() request itself as, if I understand it correctly, the get request is not formed yet. The program fails at the post request to http://localhost:10001/dprouter






Thank you.






Hi Alex,






The issue is strange, Possible to share ur complete code (With Manifest)? we can have a look and suggest






Thanks



Mahesh






Mahesh, 






Yes, sure.



(attached complete code without urls in config files - they are working as the access token is being successfully created).






Thank you.






Try checking the network call and provide us the response in that.






400 status code occurs when the domain is not whitelisted in manifest.yml. The url specified in manifest.yml must be of https.






Thanks,



Raghuram.






 





Raghuram,








The domain is whitelisted in manifest.yml - it starts with "https". I simply removed it when uploading plug.zip



The POST request with the get request info to http://localhost:10001/dprouter is failing.



Ordinary GET requests (not using OAuth) are working OK.






Is it simply how the error response from the remote api is being expressed by? I won't receive the original json with {"code": 400} and other tech info?






Thank you.



requestinfo_26525.pnggetrequest_26525.png


Raghuram,






GET works when the url is https://example.com and doesn't work when the url is https://example.com/api



whitelisted-domains:
- 'https://example.com'





Hi Alex,






Do you still experience the problem, try hitting https://example.com/api from browser $request should give you the same output.






Please keep us updated






Thanks



Mahesh






Hi Mahesh,






Resolved.



The "Authorization" header with access_token was ingnored by the server. They required implicit mentioning of access_token in the params of the url.






Thank you,



Alex




Thanks Alex, thanks for keeping us updated.