Pinterest denying access from Google App Engine (403)

余生颓废 提交于 2019-12-10 18:45:36

问题


Using an oauth accessToken, I am able to retrieve the user's info through:

https://api.pinterest.com/v1/me/?fields=first_name%2Cid%2Clast_name%2Curl%2Cusername%2Cimage&access_token=xxxx

which from a desktop or even ec2 returns:

{
   "data": {
   "username": "yyyt",
   "first_name": "yyyr",
   "last_name": "",
   "url": "https:\/\/www.pinterest.com\/yyyt\/",
   "image": {
      "60x60": {
        "url": "https:\/\/s-passets-cache-ak0.pinimg.com\/images\/user\/default_60.png",
        "width": 60,
        "height": 60
      }
    },
    "id": "1234567890"
  }
}

However, when the same query is made from appengine, a 403 error is returned with the details:

{
    "message": "Forbidden",
    "status": 403
}

I can't find any information about why Google AppEngine may be specifically blocked, and since their API has come out of Beta, I'm not sure a reason why it would be.

This earlier question: Pinterest API - returning 403 on EC2 Instance suggested that they were blocking ec2 because the api was still unofficially supported, but ec2 access does in fact seem fine now, so I'm not sure why they would block google.

Can anyone suggest a workaround not involving a proxy, or refer me to a reason why the access might be forbidden?


回答1:


or refer me to a reason why the access might be forbidden?

Unfortunately I ran into the same issue today when I tried to access the Pinterest web-site (not the API) via App Engine.

Looking at the 403 error page that is returned by Pinterest following a HTTP request from App Engine it seems that the reason is that Pinterest doesn't like bots and intentionally rejects HTTP requests by App Engine or the App Engine dev server.

When trying to access Pinterest via CURL, I noticed that Pinterest rejects all HTTP requests that have the string App Engine in the User-Agent HTTP request header, but Pinterest does happily accept any other (random) User-Agent string.

Because App Engine, as stated in the documentation, automatically appends the string "AppEngine-Google (+http://code.google.com/appengine; appid: APPID)" to the User-Agent HTTP request header, I suspect there is no way of circumventing this.



来源:https://stackoverflow.com/questions/33287840/pinterest-denying-access-from-google-app-engine-403

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!