Reputation: 598
I am using cordova-plugin-facebook4
version 1.7.4 for facebook share in my app. I got an error while sharing one post to facebook.
{errorMessage : "Facebook error: {FacebookServiceException: httpResponseCode: -1, facebookErrorCode: 190, facebookErrorType: null, message: Error validating access token: The user has not authorized application XXXXXXXX.}" }
From the facebook docs, I came to know that this error occurs when user de-authorizes my app. So I want to login again and obtain a new access token.
In the Facebook docs, I came to know that facebook sends error code 190 when this error occurs. I am able to see the facebookErrorCode
field in my error response.
My problem is I am unable to parse the error response to get the facebook error code. I tried few JSON parse and JSON stringify methods. But nothing worked. I am unable to obtain the error code.
Can anyone help me in parsing the error response and getting the error code ?
UPDATE
Here is my code sample
facebookConnectPlugin.showDialog(
{ method: "share_open_graph",
action: 'og.likes',
object: JSON.stringify({
object:'https://developers.facebook.com/docs/',
})
},
function (response) {
console.log(JSON.stringify(response));
DialogService.showToast('FB_SHARE_SUCCESS', 'Short', 'Bottom');
},
function (response) {
console.log('share failed. ',response);
if(response.errorMessage.facebookErrorCode == 190){
fblogin.then(
function(response){
share();
},
function(error){
//
}
)
}else{
DialogService.showToast('FB_SHARE_FAILED', 'Short', 'Bottom');
}
}
);
I am able to post to facebook if the user authorizes the app for posting. If the user de-authorizes, I am unable to capture the error code 190.
Upvotes: 0
Views: 55