2

I am following this https://dev.twitter.com/oauth/application-only

def get_bearer_token(self):
    data = {"grant_type": "client_credentials"}
    headers = {"Authorization": "Basic " + self.encoded_cred}
    r = requests.post("https://api.twitter.com/oauth2/token",
                      data=data, headers=headers)
    res = r.json()
    if res.get('token_type') != 'bearer':
        raise Exception("invalid type")
    self.access_token = res['access_token']

def search(self, q):

    data = {"count": 100, "q": q}
    headers = {"Authorization": "Bearer " + self.access_token}
    r = requests.get("https://api.twitter.com/1.1/search/tweets.json", data=data, headers=headers)
    print r.status_code
    print r.text

I was able to get an access_token but the search API call returns 400 with no content. Any idea?

Similar to this https://stackoverflow.com/questions/24102409/twitter-application-only-auth-returning-empty-response but no answer yet

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.