Skip to content Skip to sidebar Skip to footer

Pinterest Api - Returning 403 On Ec2 Instance

I'm attempting to retrieve the number of Pins for a given URL. I created this Python script, which takes two separate URLs and prints out the amount of Pins for each. When I run

Solution 1:

Not an answer, but hopefully this will save someone else an hour trying this approach: Pinterest, unsurprisingly, appears to also be blocking requests from tor exit routers.

I had the same problem with the same endpoint and narrowed it down to EC2 + Pinterest as well. I attempted to circumvent it by routing the request through tor.

classPinterestService(Service):
    service_url = "http://api.pinterest.com/v1/urls/count.json?callback="
    url_param = 'url'defget_response(self, url, **params):
        params[self.url_param] = url

        # privoxy listens by default on port 8118# on the ec2 privoxy is configured to forward# socks5 through tor like so:# http://fixitts.com/2012/05/26/installing-tor-and-privoxy-on-ubuntu-server-or-any-other-linux-machine/

        http_proxy  = "socks5://127.0.0.1:8118"

        proxyDict = { 
          "http"  : http_proxy
        }

        return requests.get(self.service_url, params=params, proxies=proxyDict)

I have cycled through numerous exit routers and the response is consistently { "status": 403, "message": "Forbidden" }

For a solve I am going to go through a private http proxy server

Solution 2:

This question was filed a few years ago, and the current answer I believe is out of date. EC2 now runs the above script with a successful response without the need for a proxy. I came across this question while investigating my own similar issue with Google App Engine.

Solution 3:

Pinterest is probably blocking requests from IP blocks owned by Amazon, resulting in the 403: Forbidden error. Pinterest doesn't have official support for their API, so (my supposition is) that they are blocking the largest possible sources of commercial usage of their API. You can test this by using an instance from a non-AWS provider.

Post a Comment for "Pinterest Api - Returning 403 On Ec2 Instance"