How to make calls to Twitter API using Postman cli

2019-02-16 04:32发布

问题:

I have followed the steps required to create a new application and getting consumer key, secret pairs and also the token access details. Now I would like to make calls to Twitter Rest API, using chrome Postman client.

How should I pass the customer key, secret, token etc details to the request? I have tried to pass them as headers and also tried to pass them by selecting OAuth1.0 option in postman client but I am getting errors:

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

回答1:

I know this is old, but in case anyone is still facing this issue, the following steps worked for me:

  1. In Authorization tab, select OAuth 1.0
  2. Enter your consumer key, consumer secret, access token and access token secret
  3. Enable “Add params to header” and “Auto add parameters”
  4. Send the request

I hope that helps.



回答2:

Juliana Chahoud's answer updated for 2018:

The add authorization data has been moved to the left column and requires you to select the drop down menu to change it to "Request Headers".



回答3:

Postman creates 6 character nonce, Twitter needs 32-character Nonce. So you can use any random value, I used ABCDEFGHIJKLMNOPQRSTUVWXYZ123456 (length=32)



回答4:

You must not pick Add params to header (pick will failed) You don't need to care about Nonce



回答5:

If anyone reaches this in 2017, my problem was the nonce too but the one with length 32 didn't work for me. I checked the tutorial and used the one posted there and it started working. Make sure you choose postman to add the authorization data to the headers and not the body.

This is my working nonce: kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg



回答6:

For me, Postman created 11 character Nonce. I got the correct Twitter API response with the 11 character Nonce.



回答7:

Apart from the authentication settings that are taken from twitter developer console, when searching q=target_user_id it worked as opposed from q=@target_user_id, where I got the error 32, could not authenticate you.

So, after numerous attempts, what made a difference was just removing the "@" symbol from the q parameter value.