32: Could not authenticate you. direct_messages/events/new



Hello friends!

I’m sitting with Twitter API for the second day and this causes anger.

The methods of GET work fine. But the methods of POST work do not understand how. Half of the references in the documentation are not relevant. It is almost impossible to use it.

Now that I’ve lowered the steam, I’ll ask my question.

I’m trying to use a method: POST direct_messages/events/new (message_create).

Here are my headlines:

Authorization: OAuth oauth_consumer_key="*****", oauth_nonce="1519978171", oauth_signature_method="HMAC-SHA1", oauth_token="*****", oauth_timestamp="1519978171", oauth_version="1.0", oauth_signature="mAya3KczQVnnM3TjIF33GWErrbI%3D"
Content-Length: 123
Content-Type: application/json

Request url: https://api.twitter.com/1.1/direct_messages/events/new.json

Post fields:


Twitter response:
{"errors":[{"code":32,"message":"Could not authenticate you."}]}

I believe that the problem is in the header Authorization, namely, in the generation of the signature. I do not see any other problems. However, in other methods (for example, POST statuses/update), everything is fine.

By the way, it’s funny that the POST statuses/update negatively refers to the Content-Type header with a value application/json. Rave.


Indeed, the error was in the generation of the signature OAuth.

JSON body is not included in the generation of the OAuth signature.