本文介绍了Pinterest拒绝Google App Engine的访问(403)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用oauth accessToken,我可以通过以下方式检索用户的信息:

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



  {
data:{
用户名: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
}
}

然而,当相同的查询由appengine创建时,会返回403错误的详细信息:

  {
消息:禁止,
状态:403

我找不到任何关于为什么Google AppEngine可能会被封锁的信息,他们的API已经发布了Beta版,我不确定它会是什么原因。



以前的问题:中所述,ngine会自动附加字符串AppEngine-Google(+ http://code.google.com/appengine; appid:APPID) User-Agent HTTP请求标头,我怀疑没有办法绕过这个。


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?

解决方案

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.

这篇关于Pinterest拒绝Google App Engine的访问(403)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 19:30