Question Related to REST API



This is the URL of google maps api. Which returns json data if we pass the key at the last. and hit that url from our browser directly.
So is there anything like that in twitter as well? By which we can pass our consumer key or something like that at the end of link like this
Because without any tokens if we hit this URL then its giving error : Bad Authentication data Code : 215

Please help me. i am finding this from very long and have no luck.
Please Thank You So Much.


You need to include authentication tokens in the header of the request. It’s not as simple as just adding a get parameter. I’d look into using a framework. If you tell me which language you’re developing in I can help point you towards one.


I am developing in Android.
But the thing is that i want to see the JSON data in browser the way google maps’ link shows.
Are you getting what i am asking?


Yes, I understand what you are asking. What I’m telling you is that it doesn’t work like that. As I said, you have to formulate a http request with authentication information in the headers.


You could probably find some kind of REST API testing tool that enables you to add some Twitter OAuth tokens in the header, to retrieve the JSON data, if you really need it in a browser. If you’re building an app, I’d say that’s pretty unusual, as you’d want to consume the JSON in the application code. We provide Twitter Kit in Fabric to access the Twitter API on Android.


Yeah thats what i am asking that what is the keyword to insert into url header.
just like google maps link key=your_key
So what is that for twitter api


Yeah thats what i am asking that what is the keyword to insert into url header.
just like google maps link key=your_key
So what is that for twitter api
Help me with this because i am literally stuck into my app just because of this.


When I say header I don’t mean a GET parameter. I mean you need to pass an Authorization header.


But what i am asking is that what are the GET parameters for twitter.
Is it possible to pass GET parameters to get JSON data.


Every response from Twitter is in JSON form. You can pass additional data via GET parameters but until you authenticate your requests with the authorization header, you won’t get anything besides that error message.


Yeah i know that. i have created a twitter app too and have credentials too.
i tried this,
but got this
"code": 215,
“message”: “Bad Authentication data.”


I can’t really be more clear about this. That isn’t how authentication tokens work for Twitter. You do not pass them in the url like that, they are set as headers.


Can you give me a little example for that, how header works?
Because i am trying with passing my credentials to url.


The difference is that Twitter’s REST API OAuth authentication requires the token in the HTTP header, not in the URL request parameters. I would try a tool like cURL or Postman to play around with getting your headers correct and loading the JSON data. But there is no way to just type in a URL into a browser and be authenticated.


So can you tell me how i can get the json data using such tools?


If you download Postman, type in the endpoint URL, select OAuth 1.0 for the authentication, enter in your consumer key and secret, your token and token secret, click “Add params to header”, and then Send.



If you are on Android, the best (in my opinion) way to interact with the Twitter API is to use Twitter Kit in Fabric, which can handle all of the authentication for you.