Page 1 of 2

Calling Twitter api (authentication issue)

Posted: Fri Feb 21, 2014 6:14 pm
by araskin3i

I think I need someone else to take a look at this code because I dont see what I am doing wrong...

I am calling https://api.twitter.com/1.1/geo/searc... API to search for a location on twitter. Other Twitter API calls work great with no problem but this one is constantly returning the following error message:

{"errors":[{"message":"Bad Authentication data","code":215}]}

Here is my code:

var params = {};

params.lat = Appery("labelLat").text();
params.long = Appery("labelLong").text();
params.accuracy = Appery("labelAccuracy").text();
params.query = Appery("searchbarTwitterPlace").val();
params.granularity = "poi";
var authHeader = EncodeHelper.getHeader('https://api.twitter.com/1.1/geo/searc...', params);

params.Authorization = authHeader;
serviceTwitterSearchPlace.execute({data: params});

I know that the EncodeHelper.getHeader works OK because I call other Twitter APIs with it and it works fine. Though admittedly this is the one that has the most number of parameters.

Can anyone see why I am having a 'bad authentication data' error?


Calling Twitter api (authentication issue)

Posted: Fri Feb 21, 2014 7:30 pm
by Maryna Brodina

Hello!
Is Authorization a header parameter? Please check in console what data you send.


Calling Twitter api (authentication issue)

Posted: Mon Feb 24, 2014 4:11 pm
by araskin3i

Yes it is a header parameter. I can see the parameters in the console and they seem to match what I am using to generate the header (above).


Calling Twitter api (authentication issue)

Posted: Mon Feb 24, 2014 4:27 pm
by araskin3i

Here are the request and response screen shots.... Image

Image


Calling Twitter api (authentication issue)

Posted: Mon Feb 24, 2014 6:02 pm
by Kateryna Grynko

Hi Alon,

Take a look at here please:
http://stackoverflow.com/questions/12...


Calling Twitter api (authentication issue)

Posted: Mon Feb 24, 2014 6:44 pm
by araskin3i

Thanks Katya. I have all ready read as much as I could on the www before posting this.

Here is what really kills me I can call other twitter APIs with no problem but as soon as I call THIS one it comes back with 'Bad Credentials'.


Calling Twitter api (authentication issue)

Posted: Mon Feb 24, 2014 8:20 pm
by Kateryna Grynko

Alon,

Could you please post a screenshot of service request parameters?


Calling Twitter api (authentication issue)

Posted: Mon Feb 24, 2014 8:32 pm
by araskin3i

Here you go...

Image


Calling Twitter api (authentication issue)

Posted: Mon Feb 24, 2014 10:01 pm
by Kateryna Grynko

Alon,

How do you get authorization code? Most probably, it is incorrect.


Calling Twitter api (authentication issue)

Posted: Mon Feb 24, 2014 10:03 pm
by araskin3i

It's exactly what I thought. Problem is other calls to Twitter API works with out a problem. For example, I can update the twitter status and there are no issues. So the auth code must be valid if I can use it to update my status, just not with THIS particular API call....