简体   繁体   English

接受来自外部域的POST请求? (Google App Engine)

[英]Accept POST requests from external domain? (Google App Engine)

I can't seem to get my app to accept POST requests from a different domain. 我似乎无法让我的应用接受来自其他域的POST请求。 I'm trying to make an PayPal IPN handler in my app. 我正在尝试在我的应用程序中创建一个PayPal IPN处理程序。

When a user clicks the "Subscribe" button on my page, PayPal sends an IPN (a POST), to my IPN handler. 当用户单击我页面上的“订阅”按钮时,贝宝将IPN(POST)发送到我的IPN处理程序。

I can see in my AppEngine logs that a POST request is received, but it is empty (eg no arguments, my logging.debug messages aren't showing up in the logs, etc.) 我可以在AppEngine日志中看到已收到POST请求,但该请求为空(例如,无参数,logging.debug消息未显示在日志中,等等)。

So I test my handler by making a POST to it within my app, and the handler works as expected. 因此,我通过应用程序中对其进行POST来测试我的处理程序,该处理程序可以按预期工作。

I'm assuming it's a security feature to not accept POSTs from outside sources? 我假设这是一种安全功能,不接受来自外部来源的POST? If so, how do I make my app accept POSTs from PayPal? 如果是这样,我如何使我的应用程序接受来自PayPal的POST?

Here's what my handler looks like at the moment (it's just for testing): 这是我的处理程序当前的样子(仅用于测试):

class BaseHandler(tornadotoad.mixin.RequestHandler, tornado.web.RequestHandler):
    # ...

class IPNHandler(BaseHandler):
    def post(self):
        if is_ajax(self.request):
            logging.info('AJAX')
        logging.info(self.request.arguments)
        self.write("This is the IPN Handler\n'")
        self.write(self.request.arguments)
        return

Thanks in advance. 提前致谢。

PS I'm using PayPal's Sandbox Test Tool to send the IPN PS我正在使用PayPal的沙盒测试工具来发送IPN

I found my mistake. 我发现了我的错误。 I put the url for the handler together with the other urls, which has login: required in app.yaml . 我将处理程序的URL与其他具有login: required URL一起放置在app.yaml

I've fixed this and now PayPal's IPN is getting through. 我已解决此问题,现在PayPal的IPN正在通过。

Thanks everyone! 感谢大家!

A few hunches here. 这里有一些预感。

  1. Maybe "/ipn" is not being routed to IPNHandler. 也许“ / ipn”没有被路由到IPNHandler。 Perhaps another deprecated handler? 也许是另一个不赞成使用的处理程序?

  2. Maybe the app version you are looking at in your logs is not the same as the one you have. 也许您在日志中查看的应用程序版本与您拥有的应用程序版本不同。 Perhaps you can deploy a new version of your code and test against the new one. 也许您可以部署代码的新版本并针对新代码进行测试。

  3. Maybe the POST request Paypal is sending you has no arguments. 也许POST请求Paypal发送给您没有参数。

PS More info on how you are performing tests from Paypal's end, showing other relevant parts of your code, and any other relevant info could help. PS从贝宝(Paypal)端了解有关您如何执行测试的更多信息,显示代码的其他相关部分,以及任何其他相关信息都可以提供帮助。 :) :)

Just a hunch, and I might be way out of my league here but for tornado I don't seem to be able to find either a method or an attribute of that name in the docs ... 只是预感,我可能不在这里,但是对于龙卷风,我似乎无法在文档中找到该名称的方法或属性...

At least for webapp I believe arguments is an instance method: 至少对于webapp,我认为arguments是一个实例方法:

 logging.info(self.request.arguments())

see the docs here . 请参阅此处的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM