使用apiclient.discovery.build进行代理商api

时间:2013-11-23 23:49:58

标签: python-2.7 oauth-2.0 google-reseller-api

我正在尝试为包含service的python-2.7中的reseller api创建oauth 2.0。 Oauth 2.0工作正常,因为我已经确认我可以获得access token。我有此错误消息,因为我找不到适当的经销商服务文档。尽管阅读了apiclient.discovery.build中的代码,但任何人都可以帮我识别问题(问题出在本消息的最后部分)。

这是错误:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "C:\xampp\htdocs\reseller-asteriainteractive\oauth2client\appengine.py", line 777, in setup_oauth
    resp = method(request_handler, *args, **kwargs)
  File "C:\xampp\htdocs\reseller-asteriainteractive\main.py", line 74, in post
    customer_document = customers.insert().execute(decorator.http())
  File "C:\xampp\htdocs\reseller-asteriainteractive\apiclient\discovery.py", line 583, in method
    raise TypeError('Missing required parameter "%s"' % name)
TypeError: Missing required parameter "body"

这是我的代码:

class CustomerCreateHandler(BaseHandler):
  @decorator.oauth_aware
  def post(self):
    admin_user = users.is_current_user_admin()
    user = users.get_current_user()
    if user:
      if decorator.has_credentials():
        customers = reseller_service.customers()
        customer_document = customers.insert().execute(decorator.http())
        self.redirect('/customer/create/')

如何构建reseller_service?我应该在哪里放置“body”参数?

1 个答案:

答案 0 :(得分:0)