osome-iu / botometer-python

A Python API for Botometer by OSoMe
https://botometer.osome.iu.edu
MIT License
371 stars 59 forks source link

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://botometer-pro.p.rapidapi.com/2/check_account #50

Closed SamerAl-khateeb closed 4 years ago

SamerAl-khateeb commented 4 years ago

I used to use BotOrNot API when it was with Mashape but now my code does not work. SO I created an app with RapidAPI and obtained the rapidapi_key. I also did a new twitter app. I installed all the dependencies and my code still does not work! So I decided to run the example provided to make sure the API works but still no luck when I run it. I keep on getting this error Traceback (most recent call last): File "BotOrNot.py", line 16, in <module> result = bom.check_account('@ACCOUNTNAME') File "~/pythonEnvs/Google_Env/lib/python3.7/site-packages/botometer/__init__.py", line 132, in check_account bom_resp.raise_for_status() File "~/pythonEnvs/Google_Env/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://botometer-pro.p.rapidapi.com/2/check_account which does not seems to be in the list of possible error provided here I would really appreciate anyhelp on why I am getting this error!

yang3kc commented 4 years ago

Without further information on the environment and the content of your script, it's really hard to determine the cause of the error.

My guess would be that the RapidAPI key is not correct.

clayadavis commented 4 years ago

To build off of @yangkcatiu, Make sure you're providing the RapidApi key in the X-RapidApi-Key request header. It's easy to forget and would lead to this error.

SamerAl-khateeb commented 4 years ago

@yangkcatiu @clayadavis thank you both for helping out. I am using python virtual environment with Mac OS. Here is the test code I am trying to get to work

import botometer

rapidapi_key = "myKeyHere" # now it's called rapidapi key
twitter_app_auth = {
    'consumer_key': 'myKeyHere',
    'consumer_secret': 'myKeyHere',
    'access_token': 'myKeyHere',
    'access_token_secret': 'myKeyHere',
  }
bom = botometer.Botometer(wait_on_ratelimit=True,
                          rapidapi_key=rapidapi_key,
                          **twitter_app_auth)

# Check a single account by screen name
result = bom.check_account('@username')
print(result)

am I missing any key? in the code I put my the correct keys instead of "myKeyHere" and I put an actual Twitter username instead of "@username"

SamerAl-khateeb commented 4 years ago

@clayadavis @yangkcatiu thank you both. I just solved the issue. I had to click on the "Subscribe to Test Endpoint" button, once I clicked it my API become active and was able to make a request and get results.

yang3kc commented 4 years ago

Good to hear that!