Hi, my app is requesting data from a web service that requires OAUTH authentication. I have been able to get a OAUTH token, using communications.makeOAuthRequest and I can use that token to fetch data. The reponse I get back is HTTP 200 with a JSON formatted payload. All good so far.
The token is valid for 2 hrs and when expired, the web service sends back an HTTP 401 (unauthorized) response. When that happens, I need my code to trigger a token_refresh to acquire a new token from the OAUTH server (standard OAUTH stuff), however the makeWebRequest does not accept the 401 repsonse from the web service, instead I get a -400 responseCode in my makewebrequest callback (invalid response body data)
I set responseType => HTTP_RESPONSE_CONTENT_TYPE_JSON for my makewebrequest calls because the data I receive from the service is JSON formatted, so I have to (I think). Now with the 401 response that does not seem to be the case, I am not sure what ends is vilotaing the rules here, either the web service, or CIQ. Here is a screnshot of the HTTP traffic:
One solution would be trigger a token_refresh each time I get a -400 response in my callback but Ideally I'd like to be able to read the different error responseCodes that I get from the web service, so that I know what went wrong. Any ideas how I could work around this?
TIA
/Fredrik