Getting {"errors":[{"message":"Bad Authentication data","code":215}]} while using Search API?


#1

Hello, I am trying to use search API and getting the following error:
{“errors”:[{“message”:“Bad Authentication data”,“code”:215}]}

Here is my JavaScript:

			function searchTwitter(){
			     var _url  = 'https://api.twitter.com/1.1/search/tweets.json?q=%23dhoni';

			    $.getJSON(_url,function(data){				
				
	                            ...........
				    ...........
				
			    });
			}

Can anyone please help me to resolve this issue?


#2

The Search API in 1.1 requires OAuth authentication and can’t be securely accessed using client-side Javascript.


#3

so where we have to made changes for that ?


#4

So how would you add it, this is my python code

import twitter

twitter_api=twitter.Twitter(domain=“api.twitter.com”, api_version=‘1.1’)
WORLD_WOE_ID = 1 # The Yahoo! Where On Earth ID for the entire world
world_trends = twitter_api.tweets._(WORLD_WOE_ID) # get back a callable
[ tweet for tweet in world_trends()[0][‘trends’] ]

and I also have a Oauth login that I took from the book 21 recipes for mining twitter

import os import sys import twitter

from twitter.oauth import write_token_file, read_token_file
from twitter.oauth_dance import oauth_dance

Go to http://twitter.com/apps/new to create an app and get these items

See also http://dev.twitter.com/pages/oauth_single_token

APP_NAME = 'TestApplicaionAMaggio’
CONSUMER_KEY = 'XXXXXX’
CONSUMER_SECRET = ‘XXXXXX’

def oauth_login(app_name=APP_NAME,
consumer_key=CONSUMER_KEY,
consumer_secret=CONSUMER_SECRET,
token_file=‘out/twitter.oauth’):

try:
    (access_token, access_token_secret) = read_token_file(token_file)
except IOError, e:
    (access_token, access_token_secret) = oauth_dance(app_name, consumer_key,
            consumer_secret)

    if not os.path.isdir('out'):
        os.mkdir('out')

    write_token_file(token_file, access_token, access_token_secret)

    print >> sys.stderr, "OAuth Success. Token file stored to", token_file

return twitter.Twitter(auth=twitter.oauth.OAuth(access_token, access_token_secret,
                       consumer_key, consumer_secret))

if name == ‘main’:

oauth_login(APP_NAME, CONSUMER_KEY, CONSUMER_SECRET)

#5

https://api.twitter.com/1.1/followers/ids.json?screen_name=xaib786

I am trying to get the list of followers ids but this error is displayed
{“errors”:[{“message”:“Bad Authentication data”,“code”:215}]}


#6

Are you sending authentication with your request? API v1.1 requires OAuth 1.0A or our OAuth 2-based app-only auth on all requests. Check out [node:10639].


#7

so u mean we cant acces twitter api directly writinig link to browser bar like:.
https://api.twitter.com/1.1/search/tweets.json?q=%23heartbreaker??
…then how we gonna acces??
thx


#8

What exactly do we have to put in the authentication area? Do we put the consumer key, the consumer secret, the access token, the access token secret, or all 4? It would be really helpful if I could see a sample query that someone else has got working just so I can use it as a model sample?

Thank you!


#9

What exactly do we have to put in the authentication field? Do we put the consumer key, the consumer secret, the access token, the access token secret, or all 4? It would be really helpful if I could see a sample query that someone else has got working just so I can use it as a model sample?

Thank you!


#10

dcdcdc