HTTP/1.1 401 Authorization Required Error!


#1

Getting Error 401 while sending the below request for stream api .
however when i just try using curl with authorization header it works properly .
Please advice what m doing wrong.

REQUEST

GET /1.1/statuses/sample.json HTTP/1.1
Accept: /
User-Agent: Qapla
Content-Type: application/x-www-form-urlencoded
Authorization: https://stream.twitter.com/1.1/statuses/sample.json?language=en&oauth_consumer_key=xxxxxx&oauth_nonce=u4a3R_n&oauth_signature_method=HMAC-SHA1&oauth_timestamp=153693&oauth_token=xxxxxx&oauth_version=1.0&oauth_signature=R2qVlT2aLVgi8SMA%3D
Host: stream.twitter.com

ERROR RESPONSE

HTTP/1.1
401
Authorization
Required
cache-control:
must-revalidate,no-cache,no-store
connection:
close
content-length:
266
content-type:
text/html
date:
Fri,
14
Sep
2018
15:19:31
GMT
server:
tsa
www-authenticate:
Basic
realm=“Firehose”
x-connection-hash:
cd3e38a2d55e0a8831776b96d862d3a2


#2

Try removing the language parameter. I’m pretty sure you can’t pass that along with the GET statuses/sample endpoint.


#3

You’re sending a GET to statuses/filter but your Authorization header refers to statuses/sample - are you sure you’ve got the OAuth signature correct here? What language and client library are you using?


#4

Thanks for the reply . that was a typo . edited my original query .
It still did not work so i changed the authorization to below format instead of encoded url-
oauth_consumer_key=“xxx”, oauth_nonce=“xxx”, oauth_signature=“xxx”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“xxx”, oauth_token="xxx

M using liboauth & c++14


#5

I changed the autorization header format . its working now . however passing language param do work . ./Eagle

GET /1.1/statuses/sample.json?language=en HTTP/1.1
Accept: /
User-Agent: Qapla
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth language=en,oauth_consumer_key=xxx,oauth_nonce=xxx,oauth_signature_method=HMAC-SHA1,oauth_timestamp=xxx,oauth_token=xxx,oauth_version=1.0,oauth_signature=xxx
Host: stream.twitter.com


#7

@AarifMonu - Please search the forums to see if someone else has already addressed your issue. If you don’t find anything that helps, please post a new topic. Your response is off-topic from the original post and I am marking it as such.

@ChopdeVikram - Please never share your tokens, as others might try to use them maliciously. I’m glad to hear that you got things working. I’m confused though… are you still experiencing issues?


#8

Hi LeBraat ,

Thanks . issue is resolved.
tokens i presented were already truncated and were not original .

Regards,
Vikram Chopde


#9