How to setup google pub/sub subscription to call firebase function

不想你离开。 提交于 2019-12-24 07:49:07

问题


I want to have a push subscription, but when I try to add this firebase function https://us-central1-myproject-dev.cloudfunctions.net/api/conversation as Endpoint Url, it says

The supplied URL is not registered in the subscription's parent project. Please see documentation on domain ownership validation .

The problem is I can't verify that https://us-central1-myproject-dev.cloudfunctions.net is my domain, which of course is not

Any suggestion?


回答1:


I found a solution in case any body else has same issue

1) When adding a property in Google Search Console, select the method URL prefix and enter the url of the function you will create in step 3 (i.e. https://my-project.cloudfunctions.net/googleDomainVerification).

2) Select the method HTML tag and copy the meta-tag.

3) Create a https function that you push on Firebase Cloud Function. Don't forget to copy your meta-tag from step 2:

    exports.googleDomainVerification = functions.https.onRequest((req, res) => {
        res.status(200).send('<!DOCTYPE html> <html> <head> YOUR_META_TAG_HERE </head> <body> </body> </html>')
    })

4) Wait a minute then press "Verify" on the Google Search Console

Done! now you can use https://my-project.cloudfunctions.net/googleDomainVerification or https://my-project.cloudfunctions.net/googleDomainVerification/mysubfunction in subscription




回答2:


Took me half a day but I finally noticed that Google adds a "/" to the end of the endpoint URL when adding it to the domain verification function.

After verifying your endpoint URL as stated above:

  1. In your Google Cloud Platform go to API & Services
  2. Go to Domain Verification
  3. Add your verified endpoint URL to the project.
  4. Note that if your endpoint URL is https://aaa/bbb/ccc Google will add it to the verified domains as aaa/bbb/ccc/
  5. When creating a push subscription, enter aaa/bbb/ccc/ as your endpoint URL.


来源:https://stackoverflow.com/questions/57791866/how-to-setup-google-pub-sub-subscription-to-call-firebase-function

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