63

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."
    }
  ]
}
DGinzberg
  • 146
  • 9
learner
  • 6,062
  • 14
  • 79
  • 139
  • Try following the steps mentioned [here](https://getpostman.com/docs/helpers) – elssar Sep 21 '15 at 02:15
  • For anyone wondering, there is now a Twitter Public Workspace that walks you through using the Twitter API directly in Postman with complete documentation: https://www.postman.com/twitter/workspace/twitter-s-public-workspace/overview – Arlemi Apr 07 '21 at 14:28

9 Answers9

82

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

enter image description here

starball
  • 20,030
  • 7
  • 43
  • 238
Juliana Chahoud
  • 1,037
  • 9
  • 5
  • 12
    I don't have `Auto add parameter` – CodyBugstein Mar 29 '16 at 04:27
  • 4
    Postman was updated after I posted this answer. In the current version I am using only 'Add params to header'. – Juliana Chahoud Jun 09 '16 at 21:33
  • 4
    I cannot make it work! I tried Pratik solution, setting the nonce to 32 chars length, but nothing, still having the code 32. I don't wan't to duplicate the question, but need some help. thanks – Rodrigo E. Principe Aug 08 '16 at 04:13
  • 1
    Make sure that your include a **user_id** or **user_name** parameter on the request or Twitter will not authenticate the request. I have it working with a 6 character nonce and "Add params to Header" only checked – D. Gibbs Oct 19 '16 at 17:54
  • You should not need to include a user_id or user_name. – Andy Piper Dec 12 '16 at 11:11
  • Is there a way to generate 32 chars in nonce instead of 6? Seems that when I run tests in collection runner it regenerate nonce so my authorization fails. – Denis Koreyba Jan 18 '17 at 14:53
  • 1
    Full URL for your convenience https://api.twitter.com/1.1/statuses/mentions_timeline.json if you still can't get it to work, your computer's clock might be wrong, see my answer at http://stackoverflow.com/a/42741215/539149 – Zack Morris Mar 11 '17 at 22:11
  • @juliana-chahoud how can i write this in javascipt, the postman url, authorisation params, headers etc. – abhit Jun 14 '17 at 09:35
  • For me this problem happens when I do a POST not a GET. GET works fine. POST: https://api.twitter.com/1.1/statuses/update.json?status=Hello World! – mancocapac Nov 13 '17 at 20:51
  • when I put here https://apigee.com/console/twitter it's work but when I put the data with the postman ; it want work :( – Elshan Mar 08 '18 at 11:20
  • 3
    This works in 2018 ..! Thanks . The Postman client has been changed its UI and there is a dialog box called "Add authorization data to", We should select the "Request Headers". – Senura Dissanayake Apr 29 '18 at 05:04
  • Old answer... currently does not work 2019.. is it an issue with postman? – Julian Silvestri Oct 06 '19 at 19:26
27

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".

Postman 2018

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Nathaniel Ruiz
  • 484
  • 6
  • 12
7

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

Pratik Patil
  • 99
  • 1
  • 7
6

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

enter image description here

Haha TTpro
  • 5,137
  • 6
  • 45
  • 71
  • 1
    your screen capture above indicates a GET not a POST. This problem shows up when I try a POST: https://api.twitter.com/1.1/statuses/update.json?status=Hello World! – mancocapac Nov 13 '17 at 20:50
4

Add authorization data to "Request Headers"

Example Twitter API: https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=snap

enter image description here

This will generate the Authorization header. Make sure this has been generated.

enter image description here

Result

[
    {
        "created_at": "Wed Mar 01 19:37:16 +0000 2017",
        "id": 837023955454201857,
        "id_str": "837023955454201857",
        "text": "RT @yoda: other things @snap has potentially worked on:\n\ntinker toys\nbaseball cards\nonesies\ntaco tosser\nshrunken christmas tree\nwalkie talk…",
        "truncated": false,
        "entities": {
            "hashtags": [],
            "symbols": [],
            "user_mentions": [
                {
                    "screen_name": "yoda",
                    "name": "drew olanoff",
...
mon
  • 18,789
  • 22
  • 112
  • 205
2

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

2

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

sebastianf182
  • 9,844
  • 3
  • 34
  • 66
2

After following the accepted answer, make sure there are no empty spaces at the end of the token/secret key. Otherwise, it will throw the same error Could not authenticate you.enter image description here

Saurabh Padwekar
  • 3,888
  • 1
  • 31
  • 37
1

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.

codeSwim
  • 115
  • 1
  • 8