Testing rest api credentials using curl


#1

I have an app that connects to the twitter api and pulls back data OK, i have replicated the same settings on another server but it does not work so i’m trying to connect and validate the credentials from the cmd line initially to confirm that comms is all ok - what is the correct syntax to test this please ?

curl --get ‘https://api.twitter.com/1.1/account/verify_credentials.json’ --header ‘Authorization: OAuth oauth_consumer_key=“XXXX”, oauth_nonce=“XXXX”, oauth_signature=“XXXX”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1498798502”, oauth_token=“XXXXX”, oauth_version=“1.1”’ --verbose

i get the following

About to connect() to api.twitter.com port 443 (#0)

  • Trying 104.244.42.130…
  • Connected to api.twitter.com (104.244.42.130) port 443 (#0)
  • Initializing NSS with certpath: sql:/etc/pki/nssdb
  • CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
  • SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  • Server certificate:
  •   subject: CN=api.twitter.com,OU=tsa_l Point of Presence,O="Twitter, Inc.",L=San Francisco,ST=California,C=US
    
  •   start date: Jun 29 00:00:00 2016 GMT
    
  •   expire date: Sep 19 12:00:00 2019 GMT
    
  •   common name: api.twitter.com
    
  •   issuer: CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US
    

GET /1.1/account/verify_credentials.json HTTP/1.1
User-Agent: curl/7.29.0
Host: api.twitter.com
Accept: /
Authorization: OAuth oauth_consumer_key=“XXXX”, oauth_nonce=“XXXX”, oauth_signature=“XXXX”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1498798502”, oauth_token=“XXXX”, oauth_version=“1.1”

< HTTP/1.1 400 Bad Request
< content-length: 62
< content-type: application/json; charset=utf-8
< date: Fri, 30 Jun 2017 05:52:23 GMT
< server: tsa_l
< set-cookie: guest_id=v1%3A149880194338186855; Domain=.twitter.com; Path=/; Expires=Sun, 30-Jun-2019 05:52:23 UTC
< strict-transport-security: max-age=631138519
< x-connection-hash: eb806869d5c2cbe4d18c9c204ce23080
< x-response-time: 194
<

  • Connection #0 to host api.twitter.com left intact
    {“errors”:[{“code”:215,“message”:“Bad Authentication data.”}]}