在Firebase

时间:2017-12-20 12:21:41

标签: firebase google-cloud-functions actions-on-google google-assistant-sdk

Screenshot attached when I entered "Firebase deploy" command

我在使用Google Cloud功能f​​or Firebase部署webhook以及使用Firebase托管项目所需的静态资源时,尝试按照说明执行此设置:

运行firebase init,然后选择配置主机和功能。选择项目。在配置向导中,接受所有默认选项。

使用Firebase设置/服务帐户生成私钥,并使用JSON证书文件的路径编辑functions / database.js。现在填充数据库:node database.js

运行firebase deploy并记下已发布履行webhook的端点。它应该看起来像功能URL(yourGame):https://us-central1-YOUR_PROJECT.cloudfunctions.net/yourGame。该命令还将在https://us-central1-YOUR_PROJECT.cloudfunctions.net/部署静态资产。

在运行firebase部署时,我无法找到"功能URL"。它只会显示"托管网址"和"项目控制台"。 在运行" firebase部署"时附加屏幕截图。在CLI。

它的意思是"现在填充数据库:node database.js"?

2 个答案:

答案 0 :(得分:1)

关注此项目控制台网址。

然后你应该在你的项目的仪表板中,在屏幕的左侧你会看到一堆选项,其中一个名为“功能”,点击它。

您的网址应该显示在那里。

答案 1 :(得分:0)

如果您创建了一个新的Firebase项目,则 const callAPI = () => { /** * Let's not debate the merits of localstorage/cookies. */ const authToken = localStorage.getItem('authToken'); const config = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + authToken, } } fetch("some-url-that-needs-auth", config) .then((response) => { // do stuff with response data }) .catch((error) => { /** * if status code 403 and there is a refresh token, * Let's try and refresh the auth token. */ if (error.status === 403 && localStorage.getItem('refreshToken')) { /** * But why??? If both tokens are stored the same way, * how is refreshing like this more secure than a long lived auth token? */ refresh(); } else { // redirect to login page. } }); } const refresh = () => { /** * Let's not debate the merits of localstorage/cookies. */ const refreshToken = localStorage.getItem('refreshToken'); const config = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + refreshToken, } } fetch("some-url-that-refreshes-auth-token", config) .then(res => res.json()) .then((tokens) => { /** * We're refreshed. Updated tokens. */ localStorage.setItem('authToken', token.auth); localStorage.setItem('refreshTOken', token.refresh); /** * Now that we are refreshed, we should REtry the fetch that returned a 403 * due to an expired Auth Token. */ someMethodThatRetriesAnAPICall(); }) .catch((error) => { /// if status code 403. Refresh token is no good. Redirect to login. }); } 目录中的index.js在默认情况下将如下所示:

./functions

确保取消对const functions = require('firebase-functions'); // // Create and Deploy Your First Cloud Functions // // https://firebase.google.com/docs/functions/write-firebase-functions // //exports.helloWorld = functions.https.onRequest((request, response) => { // response.send("Hello World!"); //}); 函数的注释。然后保存您的项目。然后运行hellowWorld。然后,该网址将显示在您的信息中心中。