My messenger bot that was running for two months but this night something changed and for unclear reasons, I can't POST back to Facebook which returns an error as a response.
From begging:
# VS - alias for the Server running chatbot
# this is what should happen
1. User -> message -> FB # User sends a message via messenger
2. VS <- message <- FB # Facebook does its thing and send me REST API POST request
3. VS -> response -> FB # I send the response meant for the User
4. User <- response <- FB # Facebook forwards the response to User
# this is what is happening
1. User -> message -> FB # works
2. VS <- message <- FB # works
3. VS -> response -> FB # works
4. VS <- error <- FB # FB returns an 400 error and User gets no response
# The error response from step 4
'{"error":{
"message":"You cannot access the app till you log in to www.facebook.com and follow the
instructions given.", ### !! above !! ###
"type":"OAuthException",
"code":190,
"error_data": "{\"checkpoint_url\" : \"https:\\\/\\\/www.facebook.com\"}",
"error_subcode":459,
"fbtrace_id":"A9MjzGGqQfKY2vPsszXQemu"
}
}'
I did as said in the message field but there were no instructions on facebook.com
nor the developers.facebook.com
. I checked from the correct account.
I did change a thing in server code, but it was a simple bug fix that shouldn't have had an impact on communication with Facebook. Obviously, I have tested it and everything worked fine.
But overnight FB decided that everything was not fine and started returning errors to every response
sent (response
is the third step in the communication scheme).
Do you know what this error is about or maybe where can I find help because Facebook doesn't provide real support?
App Dashboard/Messenger/Settings
and reconfigure
your server to use it.The app has two administrator accounts, one is my usual and the other one was created specifically for this project (what was unnecessary).
Looking from my main account, I couldn't find anything that would tell me what is wrong, when writing this question, just to be sure I checked the other one. FB prompted me to change my password for security reasons because someone tried to log in from the USA (but I haven't tried to log in to this account lately).
I changed the password and looked for notifications that would tell me what was wrong. Nothing. Error response didn't change either in logs.
Today with nothing better in mind I switched from: requests.post("https://graph.facebook.com/v2.6/me/messages")
to:
requests.post("https://graph.facebook.com/v6.0/me/messages")
and checked logs, where I found this response:
"error":{
"message":"Error validating access token: The session has been invalidated
because the user changed their password or Facebook has changed the
session for security reasons.",
"type":"OAuthException",
"code":190,
"error_subcode":460,
"fbtrace_id":"Ay7KPJ9_gtv5s3ebKjm5LG_"
}}'
Now I did exactly what it said and generated a new Access Token in
App Dashboard/Messenger/Setting
and reconfigured my server. This was it.
Then from curiosity, I changed back the v6.0
to v2.6
and everything still worked fine.