How to fix error 32 "Could not authenticate you." for POST Direct Message?


#1

Hello, since yesterday i have a problem with the direct message post. I’m using oAuth and based user with Node.Js. so i use :
consumer_key: '...', consumer_secret: '...', access_token_key: '...', access_token_secret: '...' })

and surely after checking all my keys access are, this is well written and filled

i have also activated

Read, write, and direct messages

but still, it’s not working. :confused:

EDIT : i forgot; this is my code for the direct messages

 client.post('direct_messages/events/new', {
    type: 'message_create',
    message_create: {
        target: {
            recipient_id: "...",
            message_data: {
                text: "Hi"
            }
        }
    }
})

#2

What is the error message you’re getting, @DDeployer?

Hamza


#3

by adding in my code :

.catch(ex => console.log(`[ERROR] ${JSON.stringify(ex)}`))

i got this error message :

[ERROR] [{"code":32,"message":"Could not authenticate you."}]

#4

Also, i have tried with Postman (with copywriting all keys) and still, it’s getting an error :

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

With this new code :

client.post("direct_messages/events/new", {"type": "message_create", "message_create": {"target": {"recipient_id": ("4484068887"), "message_create": {"message_data": ("plop")}
}}})`

#5

Error 32 has to do with your authentication. My guess here is that you are either not using the proper consumer keys and access tokens, or you are not generating oauth nonce, oauth_signature, and oauth_timestamp properly.

Have you tried with twurl or Insomnia?


#6

Sorry for the long wait, i will try to use twurl and insomnia now.
for info, i didn’t use kind like oauth nonce , oauth_signature , and oauth_timestamp on my js script


#7

That is probably what was triggering that error.

To learn more, please read our docs on generating a request.

I suggest that you use twurl, Insomnia, or a library like TwitterOAuth to generate your request.