Search code examples
javascriptangulartwittertwitter-oauth

Getting Bad Authentication data from twitter api | Angular 2


I am using this url, can anyone tell what I am doing wrong?

https://api.twitter.com/1.1/statuses/user_timeline.json?user_token=XXXX&user_secret=XXXX&consumer_key=XXXX&consumer_secret=XXXX&screen_name=twitterapi&count=5


Solution

  • This is not the correct way to pass the OAuth tokens to the API. You need to construct correct Authorization HTTP headers and sign your request. Something more like:

    GET https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi

    Authorization: OAuth oauth_consumer_key=\"xxxxx\", oauth_nonce=\"xxxx\", oauth_signature=\"xxxx\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"xxxx\", oauth_token=\"xxx\", oauth_version=\"1.0\"\r\n