Forums

Whitelisted api not reachable

I'm trying to reach api.tripit.com which is in the whitelist. However I receive an error

Access Denied
You don't have permission to access "http://api.tripit.com/v1/list/trip/past/false/page_size/100" on this server.

Locally there is no problem, so credentials are in order. Something is blocking the access on PythonAnywhere side.

How does your request look like? How are you authenticating it on PythonAnywhere? What's the full response you're gettitg? (We need more details to debug it.)

To get the data I'm using the code provided by tripit support to be used with python 3:

from requests_oauthlib import OAuth1Session
session = OAuth1Session(TRIPIT_CONSUMER_KEY,
                  client_secret=TRIPIT_CONSUMER_SECRET,
                  resource_owner_key=TRIPIT_TOKEN,
                  resource_owner_secret=TRIPIT_TOKEN_SECRET)
url = 'https://api.tripit.com/v1/list/trip/past/false/page_size/100'
response = session.get(url)

The response I get:

Access Denied
You don't have permission to access "http://api.tripit.com/v1/list/trip/past/false/page_size/100" on this server.
Reference #18.54e1dd17.1666693604.426b167c

status_code is 403

When the same code is used locally or on Heroku, it works as intended.

That 403 error is definitely coming from api.tripit.com rather than our own systems. Perhaps they've blocked incoming requests from PythonAnywhere for some reason? You could get in touch with them to ask why.