如何设置谷歌发布/订阅以调用Firebase功能 [英] How to setup google pub/sub subscription to call firebase function
问题描述
我想要一个push
订阅,但是当我尝试将此firebase function
https://us-central1-myproject-dev.cloudfunctions.net/api/conversation
添加为Endpoint Url时,它说
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
提供的URL未在订阅的父项目中注册.请参阅有关域所有权验证的文档.
The supplied URL is not registered in the subscription's parent project. Please see documentation on domain ownership validation .
问题是我无法验证https://us-central1-myproject-dev.cloudfunctions.net
是我的域,当然不是.
The problem is I can't verify that https://us-central1-myproject-dev.cloudfunctions.net
is my domain, which of course is not
有什么建议吗?
推荐答案
我发现了一个解决方案,以防其他机构遇到相同的问题
I found a solution in case any body else has same issue
1)在Google Search Console中添加属性时,选择方法URL prefix
,然后输入您将在步骤3中创建的函数的网址(即https://my-project.cloudfunctions.net/googleDomainVerification
).
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)选择方法HTML tag
并复制元标记.
2) Select the method HTML tag
and copy the meta-tag.
3)创建一个在Firebase Cloud Function上推送的https函数.不要忘记从第2步复制您的元标记.
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)等一下,然后在Google Search Console上按验证"
4) Wait a minute then press "Verify" on the Google Search Console
完成!现在您可以在订阅中使用https://my-project.cloudfunctions.net/googleDomainVerification
或https://my-project.cloudfunctions.net/googleDomainVerification/mysubfunction
Done! now you can use https://my-project.cloudfunctions.net/googleDomainVerification
or https://my-project.cloudfunctions.net/googleDomainVerification/mysubfunction
in subscription
这篇关于如何设置谷歌发布/订阅以调用Firebase功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!