Google Pubsub subscriber that does a http PUSH to

2019-05-29 02:42发布

Is it possible to setup a pubsub topic/subscriber in one project that does a http PUSH to a cloud function in the same OR in another google project? I know there are PubSub triggers but these do not work when the pubsub topic is in another google project. Curious if this even doable with a subscriber PUSH.

Error I get thiis pubsub error INVALID_ARGUMENT if I try to create it. I wasn't sure if this was because I needed to register the endpoint (https://cloud.google.com/pubsub/docs/push#other-endpoints). However that didn't feel right because when I create a function, the URL is given to me automatically and I can hit it via Postman.

I did find this link (GCP - Verify ownership of a cloud function https endpoint for a PubSub push) and think it is url-verification related.. just want a confirmation :)

Thoughts? Did I miss some documentation somewhere?

EDIT: I think it's related to URL verification as well as using the ../_ah/push-handlers/.. path. When I register a PubSub trigger, the delivery type to the function is still a PUSH but it's to a encoded url with more of a path: https://{hash}-dot-{hash}.appspot.com/_ah/push-handlers/pubsub/projects/{project-id}/topics/prototype-contact-created?pubsub_trigger=true

1条回答
Animai°情兽
2楼-- · 2019-05-29 02:54

This was a solution I was given here: https://github.com/googleapis/nodejs-pubsub/issues/118

You need to verify this URL by going on your Google Cloud Console, API & Services, Credentials, then the Domain Verification tab. Add the url of your Cloud Functions. You will need to do that for each and every one.

Then, make sure that in the Search Console, you select the META TAG verification method, and response with that on GET requests.

if (req.method === 'GET') {
      // mine is in a settings file but you can hardcode yours for testing purposes
      return res.send(`<html><head><meta name="google-site-verification" content="${settings.google.siteVerificationCode}" /></head><body></body></html>`)
}
查看更多
登录 后发表回答