Unable to create subscription with a push end point on App Script (script.google.com)

若如初见. 提交于 2019-12-01 06:31:58

问题


I have been playing around with the Pub/Sub REST API on Google App Script.

I have tried, without success, to create a subscriber with a push end point at script.google.com. The push end point URL was created with the StateTokenBuilder API, which requires a query parameter to be present on the end point URL. The query parameter is further used to forward any request at the URL to a javascript function inside the app.

Is it allowed to have a push end point URL with a query parameter?

However, even if it is allowed, I am unable to register for a push end point at the domain script.google.com. I am required to assert ownership of any domain other than appspot.com.

Do you guys know of any workaround? Am I doing something wrong?

This is the error I am getting:

  "error": {
    "code": 400,
    "message": "Invalid push endpoint given (endpoint=https://script.google.com/macros/s/.../usercallback?state=...). Refer to https://cloud.google.com/pubsub/subscriber#create for more information.",
    "status": "INVALID_ARGUMENT"
  }

Thank you!


回答1:


I was able to get Cloud Pub/Sub Working with Apps Script. The trick is to publish your script to the chrome web store (you can leave it in draft mode). This will verify your script in webmaster tools. You then go to the Dev Console and add the published URL of the script without the trailing /exec to your push locations.

Here is an example of the new gmail push notifications that uses Pub/Sub.
https://github.com/Spencer-Easton/Apps-Script-Gmail-Push-Notifications




回答2:


Is it allowed to have a push end point URL with a query parameter?

Yes.

Do you guys know of any workaround? Am I doing something wrong?

As you noticed, now we don't support push endpoints with the domain "script.google.com". I think this is a good feature request. Do you mind adding a feature request on our issue tracker?



来源:https://stackoverflow.com/questions/30584533/unable-to-create-subscription-with-a-push-end-point-on-app-script-script-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!