Search code examples
pythonpython-2.7podio

403 Forbidden response from podio API using pypodio2


I ask this question having run out of ideas - I assumed I was doing something stupid but even if I am I can't figure out what... I'm new to python having drifted away from coding 10 years ago but I was reasonably proficient once :-D I've written a python script to query a google CSE and search for relevant items, and the idea is that it will check a Podio materials list to see if they are already listed there. So at the moment all I want to do is authenticate with Podio and grab items so I can query them in my app.

I'm trying to connect to the Podio API using the prescribed method in the docs (and in questions here, and everywhere else I have looked)

At this point literally all this script is doing is this except for the credentials replaced with the actual strings, just in case I was missing some python variable madness.

import pypodio2
from pypodio2.api import OAuthClient

c = OAuthClient(
    "<myappID>",
    '<myAPIkey>',
    '<myusername>',
    '<mypassword>'    
)

I'm using pythonanywhere as a sandbox and I am running the script from a bash console, I get this

16:26 ~/mysite $ python apitest.py
Traceback (most recent call last):
  File "apitest.py", line 15, in <module>
    'Splat_100'    
  File "/home/Trebuchet/.local/lib/python2.7/site-packages/pypodio2/api.py", line 13, in OAuthClient
    api_key, api_secret, domain)
  File "/home/Trebuchet/.local/lib/python2.7/site-packages/pypodio2/transport.py", line 41, in __init__
    urlencode(body), headers=headers)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 2135, in request
    cachekey,
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1796, in _request
    conn, request_uri, method, body, headers
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1701, in _conn_request
    conn.connect()
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1358, in connect
    sock.connect((self.host, self.port) + sockaddr[:2])
  File "/usr/local/lib/python2.7/dist-packages/httplib2/socks.py", line 496, in connect
    self.__negotiatehttp(destpair[0], destpair[1])
  File "/usr/local/lib/python2.7/dist-packages/httplib2/socks.py", line 457, in __negotiatehttp
    raise HTTPError((statuscode, statusline[2]))
httplib2.socks.HTTPError: (403, 'Forbidden'

The password, key etc are correct. The username is correct. The clientID is correct. So I must be missing something that is obvious to people used to working with APIs. Mustn't I? Thanks :)


Solution

  • Free accounts on PythonAnywhere can only access http(s) sites that are on our whitelist. If the site you're using has a publicly documented API, send a link to it to PythonAnywhere support ([email protected]) and we'll consider add it to the whitelist.