Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending phone number in recipient causes OAuthException due to insufficient permissions #46

Open
Hultner opened this issue Dec 28, 2017 · 0 comments

Comments

@Hultner
Copy link
Contributor

Hultner commented Dec 28, 2017

Background

I started playing around with this library over christmas and were having problems getting it to work while the node version Facebook provided worked flawless.

Error

I was getting error messages along the lines of

'{"object":"page","entry":[{"id":"xxxxxxxxxxxxxxxxxx","time":1514482715763,"messaging":[{"sender":{"id":"xxxxxxxxxxxxxxxxxx"},"recipient":{"id":"xxxxxxxxxxxxxxxxxx"},"timestamp":1514482714981,"message":{"mid":"mid.$cAAEiNjh2mVNmz3mRZVgnjRIp5XRk","seq":xxxxxx,"sticker_id":369239263222822,"attachments":[{"type":"image","payload":{"url":"https:\\/\\/scontent-atl3-1.xx.fbcdn.net\\/v\\/t39.1997-6\\/851557_369239266556155_759568595_n.png?_nc_ad=z-m&_nc_cid=0&oh=3692392632228223692392632&oe=759568595","sticker_id":369239263222822}}]}}]}]}'
Received message for user xxxxxxxxxxxxxxxxxx and page xxxxxxxxxxxxxxxxxx at 1514482714981 with message:
{'mid': 'mid.$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'seq': xxxxxxxxxxxxxxxxxx, 'sticker_id': 369239263222822, 'attachments': [{'type': 'image', 'payload': {'url': 'https://scontent-atl3-1.xx.fbcdn.net/v/t39.1997-6/851557_369239266556155_759568595_n.png?_nc_ad=z-m&_nc_cid=0&oh=3692392632228223692392632&oe=759568595', 'sticker_id': 369239263222822}}]}
{"error":{"message":"(#230) Requires pages_messaging_phone_number permission to manage the object","type":"OAuthException","code":230,"fbtrace_id":"xxxxxxxxxxxxxxxxxx"}}
AFTER_SEND : {"message": {"attachment": null, "metadata": null, "quick_replies": null, "text": "Message with attachment received"}, "notification_type": null, "recipient": {"id": "xxxxxxxxxxxxxxxxxx", "phone_number": null}, "sender_action": null}
RESPONSE : {"error":{"message":"(#230) Requires pages_messaging_phone_number permission to manage the object","type":"OAuthException","code":230,"fbtrace_id":"xxxxxxxxxxxxxxxxxx"}}

Now that was quite verbose but I cleaning it up a bit I could clearly see the problem as:
Requires pages_messaging_phone_number permission to manage the object combined with "recipient": {…, "phone_number": null}, something which isn't used in the reference implementation provided by Facebook.

Solution

The trivial solution were to just comment out line 31 and voila the bot worked as expected, if it's used I could add a conditional.

self.phone_number = phone_number

Conlusion

Is the phone_number field ever used?
And if so is there any reason to send it when it's null?
Adding a conditional check or simply removing it from the Recipient class would both simplify development when working building a bot from scratch but would also remove unnecessary permission dependencies.

If there's no particular reason to send null when it isn't send I'd be happy to send a pull-request with a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant