araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Calling Twitter api (authentication issue)

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?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Calling Twitter api (authentication issue)

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

araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Calling Twitter api (authentication issue)

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).

araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Calling Twitter api (authentication issue)

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

Image

araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Calling Twitter api (authentication issue)

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'.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Calling Twitter api (authentication issue)

Alon,

Could you please post a screenshot of service request parameters?

araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Calling Twitter api (authentication issue)

Here you go...

Image

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Calling Twitter api (authentication issue)

Alon,

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

araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Calling Twitter api (authentication issue)

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....

Return to “Issues”