问题
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:
- In your Google Cloud Platform go to API & Services
- Go to Domain Verification
- Add your verified endpoint URL to the project.
- Note that if your endpoint URL is https://aaa/bbb/ccc Google will add it to the verified domains as aaa/bbb/ccc/
- 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