2012-11-25 30 views
0

我遇到AppEngine和Context.IO API非常奇怪的问题。AppEngine,python-oauth2和Context.IO;消费者密钥未与请求一起发送

我正在使用contextIO2库,它使用python-oauth2

当我通过终端试用库(contextIO2)时,我没有遇到任何问题(至少现在还没有,但是我已经在几天内尝试了几次而没有问题)。

但在AppEngine上运行的代码的时候,我有时得到401 Authorization Invalid consumer key错误。我不确定是什么原因造成的,因为一分钟内请求没有问题,那么当我再次尝试请求时,我得到401,过了一段时间就会好起来,然后又不好,等等。

我通过电子邮件发送了Context.IO支持,他说当他尝试我的应用程序的url并得到错误时,“oauth_consumer_key似乎没有正确传输”。什么可能导致这个? AppEngine搞砸了请求? pythoan-oauth2错误? contextIO2错误?

这里是我的处理程序的代码之一:

class ReceiveConnectTokenHandler(webapp2.RequestHandler): 
    def get(self): 
     contextio_token = self.request.get('contextio_token') 
     cio = ContextIO(API_KEY, API_SECRET) 
     # get token's associated email 
     try: 
      token = cio.get_connect_token(contextio_token) 
     except RequestError, e: 
      if e.status_code == 404: 
       self.response.write(
        'Token %s not found. ' % contextio_token) 
       return 
      raise e 
     account = token.account 
     if not account or not account.email_addresses: 
      self.response.write(
       'Token %s has no email associated with it yet.' % contextio_token) 
      return 
     email = account.email_addresses[0] 
     # clear email's memcache 
     memcache.delete_multi(['accounts', 'no_account'], namespace=email) 
     self.response.write(
      '''%s is now connected with Context.IO. Please verify in the 
      gadget that you have granted access. You can close this window.''' % email 
     ) 

这只是对https://api.context.io/2.0/connect_tokens/{{token}}

+0

这是contextIO2库中的一个bug。我如何关闭一个主题? – john2x

+1

你能回答一个错误报告/修复吗?这可能有助于其他人。 – Greg

回答

0

发帖回答一个简单的GET按照格雷格的建议。

问题是,contextIO2库中定义它是由request_uri方法:

def request_uri(uri, method='GET', params={}, headers={}): 

这是一种常见的Python陷阱(#5 in this list)。我已经通知Context.IO支持并发送了一个请求。

相关问题