使用取()函数在谷歌App Engine的身份验证的请求:如何提供在请求的报头中的信息? [英] Authenticated request in Google App Engine using fetch() function: how to provide the information in the header of the request?

查看:544
本文介绍了使用取()函数在谷歌App Engine的身份验证的请求:如何提供在请求的报头中的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动传递,使用谷歌应用程序引擎,我的密码和ID易趣,这个页面:

<一个href=\"https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&UsingSSL=1&pUserId=&co%5FpartnerId=2&siteid=0&ru=http%3A%2F%2Fcgi5.ebay.com%2Fws2%2FeBayISAPI.dll%3FSellItem%26hm%3Dum.rundkoi376%26%26hc%3D1%26guest%3D1&pageType=1144\" rel=\"nofollow\">https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&UsingSSL=1&pUserId=&co_partnerId=2&siteid=0&ru=http%3A%2F%2Fcgi5.ebay.com%2Fws2%2FeBayISAPI.dll%3FSellItem%26hm%3Dum.rundkoi376%26%26hc%3D1%26guest%3D1&pageType=1144

(这是我从这个URL重定向到: https://signin.ebay.com ) 。下面是页面的外观如下:

早些时候,我曾问一些问题,而<一href=\"http://stackoverflow.com/questions/1901701/how-to-check-for-an-http-status-$c$c-of-401\">here非常好一个支持者建议我用code从这个链接: http://chillorb.com/?p = 195 如果你没有时间去那里,这里是该页面的样子:

所以,我认为贴code到我的编辑替换有效易趣的网址,我的ID和密码。我的ID有 seeyousoondanny ,密码为 happy1 (我创建在eBay上该帐户只是为了实验,所以我不害怕给我的ID和密码)。这里是code在我的编辑器的样子:

但是,当我运行这个code我只得到这样的:

我在做什么错在这里?

+++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++

增加:

下面是错误页面(我认为的底部,可以看到更清晰的,如果你点击链接这个图片):

+++++++++++++++++++++++++++++++++++++++++++++++ ++++

增加:

我想这code有没有语法错误:

 从google.appengine.api进口网址抓取
进口的base64URL = \"https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&UsingSSL=1&pUserId=&co_partnerId=2&siteid=0&ru=http%3A%2F%2Fcgi5.ebay.com%2Fws2%2FeBayISAPI.dll%3FSellItem%26hm%3Dum.rundkoi376%26%26hc%3D1%26guest%3D1&pageType=1144\"
authString ='基本'+ base64.en codeString的('seeyousoondanny:happy1')
数据= urlfetch.fetch(URL,标题= {'授权':authString})
如果data.status_ code == 200:
   打印内容类型:text / plain的
   打印
   打印data.status_ code


解决方案

看起来有些引号字符是一种错误的 - 倒智能引号,而不是正常的普通的ASCII普通引号字符。很难说$ P从截图pcisely $!你正在展示(来自GAE的SDK)错误屏幕显示错误在最底层的准确位置 - 你正在展示它来滚动一路到极顶,所以它并不能帮助。

在GAE像任何其他使用Python的报价是通过普通的单,双引号字符完成: ; 不可以通过倾斜,倒置或智能引号字符,如

 `

(很难清楚地显示在SO倒单引号除了作为codeblock和因为它用来标记在线code ;-)或,等等。所以,仔细检查你的code,以确保您使用的是正常的,普通类型的引号!

I am trying to pass automatically, using Google App Engine, my password and ID to eBay, to this page:

https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&UsingSSL=1&pUserId=&co_partnerId=2&siteid=0&ru=http%3A%2F%2Fcgi5.ebay.com%2Fws2%2FeBayISAPI.dll%3FSellItem%26hm%3Dum.rundkoi376%26%26hc%3D1%26guest%3D1&pageType=1144

(It is where I get redirected to from this URL: https://signin.ebay.com). Here is how the page looks like:

Earlier I have asked some questions, and here one very nice supporter suggested that I use code from this link: http://chillorb.com/?p=195 If you have no time to go there, here is how that page looks like:

So, I pasted that code into my editor substituting the valid eBay URL, my ID and password. My ID there is seeyousoondanny and the password is happy1 (I created that account on eBay just for experimenting, so I am not afraid to give out my ID and password). Here is how the code looked in my editor:

But when I run this code I get only this:

What am I doing wrong here?

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Addition:

Here is the bottom of the error page (I think it will be seen clearer if you click on the link to this image):

+++++++++++++++++++++++++++++++++++++++++++++++++++

Addition:

I guess this code has no syntax mistakes:

from google.appengine.api import urlfetch
import base64

url = "https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&UsingSSL=1&pUserId=&co_partnerId=2&siteid=0&ru=http%3A%2F%2Fcgi5.ebay.com%2Fws2%2FeBayISAPI.dll%3FSellItem%26hm%3Dum.rundkoi376%26%26hc%3D1%26guest%3D1&pageType=1144"
authString = 'Basic' + base64.encodestring('seeyousoondanny:happy1')
data = urlfetch.fetch(url, headers= {'AUTHORIZATION' : authString })
if data.status_code == 200:
   print "content-type: text/plain"
   print
   print data.status_code

解决方案

Looks like some of the quote-characters are the wrong kind -- reversed "smart quotes" rather than normal plain ordinary ASCII quote characters. Hard to say precisely from screenshots! The error screen you're showing (from GAE's SDK) shows the exact location of the error at the very bottom -- and you're showing it scrolled all the way to the very top, so it doesn't help.

In GAE like in any other use of Python quote is done via plain single and double quote characters: ' and " ; not via slanted, inverted, or "smart" quote characters, such as

`

(hard to clearly show the inverted single quote in SO except as a codeblock, since it's used to mark inline code;-) or , ", ", and so forth. So check your code carefully to make sure you're using the normal, plain kinds of quotes!

这篇关于使用取()函数在谷歌App Engine的身份验证的请求:如何提供在请求的报头中的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆