"Bad Authentication data" (Code: 215) with Twitter and Grackle

1,046 views
Skip to first unread message

Nitish Upreti

unread,
Jun 15, 2013, 1:55:51 AM6/15/13
to grac...@googlegroups.com
I am trying to access the Twitter API Users lookup endpoint. ( https://dev.twitter.com/docs/api/1.1/get/users/lookup )

I have code in my rails app as:

client = Grackle::Client.new(:auth=> { :type=>:oauth, :consumer_key=>@@APP_CONFIG['api']['twitter']['consumer_key'], :consumer_secret=> @@APP_CONFIG['api']['twitter']['consumer_secret'] })
client.users.lookup! :screen_name => "google,youtube"

To which I get the following error:

Grackle::TwitterError: post http://api.twitter.com/1.1/users/lookup.json => 400: {"errors":[{"message":"Bad Authentication data","code":215}]}
	from /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/grackle-0.3.0/lib/grackle/client.rb:296:in `handle_error_response'
	from /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/grackle-0.3.0/lib/grackle/client.rb:274:in `process_response'
	from /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/grackle-0.3.0/lib/grackle/client.rb:248:in `call_with_format'
	from /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/grackle-0.3.0/lib/grackle/client.rb:228:in `append'
	from /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/grackle-0.3.0/lib/grackle/client.rb:166:in `method_missing'
	from /Users/myth/Work/Rails Development/2020Social/socialindex/app/models/twitter.rb:18:in `fetch_api_data'
	from (irb):1
	from /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
	from /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
	from /Users/myth/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
	from script/rails:6:in `require'
	from script/rails:6:in `<main>'

Hayes Davis

unread,
Jun 16, 2013, 4:48:34 PM6/16/13
to grac...@googlegroups.com
It appears that you're not passing in all the OAuth credentials to the Grackle::Client constructor. You're passing in the consumer information but not the :token and :token_secret. Here's a doc which describes everything you need to do use Grackle and OAuth: https://github.com/hayesdavis/grackle/wiki/Grackle-and-OAuth

Hayes

Nitish Upreti

unread,
Jun 16, 2013, 10:34:25 PM6/16/13
to grac...@googlegroups.com
I am not taking any action on behalf of the user, hence no OAuth token. I just want to get the profile information for users. 

Nitish Upreti

unread,
Jun 16, 2013, 11:54:41 PM6/16/13
to grac...@googlegroups.com
I tried with OAuth token and secret as well earlier and it was giving me the same error. Tried again with the two additional parameters and not it magically works!


On Monday, June 17, 2013 2:18:34 AM UTC+5:30, Hayes Davis wrote:

Hayes Davis

unread,
Jun 17, 2013, 2:07:40 AM6/17/13
to gracklerb
Glad to hear you got it to work. And just to clarify, you always have to have an access token and token secret when using Twitter OAuth even if you're not technically doing it on behalf of another user. Twitter's dev admin page for your app has a simple interface to generate these for your own account if you don't need to do things on behalf of another user.

Hayes

Nitish Upreti

unread,
Jun 17, 2013, 2:13:56 AM6/17/13
to grac...@googlegroups.com
Thanks for the clarification. However dont you think the wiki at https://github.com/hayesdavis/grackle/wiki/Grackle-and-OAuth is a little misleading. You have outlined the two different scenario but not mentioned that we would need the OAuth token anyways.

From the page documentation it appears as if we are good with just the consumer_key and consumer_secret.

Nitish Upreti

unread,
Jun 17, 2013, 6:14:33 AM6/17/13
to grac...@googlegroups.com
The Behavior is just too weird. The code runs perfectly from rails console. However in my development environment I am now getting:

post http://api.twitter.com/1.1/users/lookup.json => 404: {\"errors\":[{\"message\":\"Sorry, that page does not exist\",\"code\":34}]}", 

Nitish Upreti

unread,
Jun 18, 2013, 3:31:46 AM6/18/13
to grac...@googlegroups.com
Fixed: Not found is not because of incorrect APPI url but incorrect screen_name.
Reply all
Reply to author
Forward
0 new messages