Unable to create subscription with a push end poin

2019-02-18 15:36发布

问题:

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?