Firebase云功能“您的客户端无权从此服务器获取URL/200" [英] Firebase cloud function "Your client does not have permission to get URL /200 from this server"

查看:439
本文介绍了Firebase云功能“您的客户端无权从此服务器获取URL/200"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚做了一个Firebase云功能:

I just made a firebase cloud function :

exports.deleteAfterSevenDays = functions.https.onRequest((req, res) => {...

我部署了功能并获得了功能URL.当我从浏览器中请求此URL时,会收到以下消息:

I deployed the function and got a function URL. When I request this url from my browser I get the following message :

错误:被禁止您的客户端无权获取URL/200 从该服务器."

"Error: Forbidden Your client does not have permission to get URL /200 from this server."

我刚刚更新到Firebase Blaze计划,因为我认为Spark计划存在局限性,但仍然无法使用.

I have just updated to firebase Blaze plan because I thought there were limitations with Spark plan, but it still doesn't work.

在我的Firebase云功能日志中,其写为​​函数执行耗时572毫秒,状态码为302".

In my firebase cloud function logs it is written "Function execution took 572 ms, finished with status code: 302".

我的cron作业由于执行失败次数过多而被自动禁用".

My cron job "has been disabled automatically because of too many failed executions".

您看到了什么问题吗?

推荐答案

云函数应该具有一个名为所有用户"的成员角色,以便无论授权如何,都可以从任何地方/任何人调用此函数.

Cloud function should have a role with member called "All users" to invoke this function from anywhere/anyone irrespective of an authorization.

未经授权:

  1. 转到云功能选项卡
  2. 选择您的云功能(复选框)
  3. 点击右侧权限"标签下的添加成员"
  4. 在新成员"下输入"allUsers"
  5. 将角色选择为云功能->云功能调用者"
  6. 保存
  7. 只需将其粘贴到浏览器中即可测试您的云功能

获得授权:

在云功能上设置授权始终是一个好习惯

It's always a good practice to set authorization on your cloud functions

注意:授权用户应调用"403禁止-您的客户端无权获取URL"引发的云函数错误.

Note: Cloud functions throwing error with "403 Forbidden - Your client does not have permission to get URL" should be called by authorized users.

简单测试:

  1. 单击顶部的Cloud shell(图标)终端

  1. Click on Cloud shell(icon) terminal in the top

类型-gcloud auth打印身份令牌

type - gcloud auth print-identity-token

复制生成的令牌

形成调用云函数时要传递的授权密钥 4.1授权:不记名的generate_token

forming Authorization key to be passed while calling cloud function 4.1 Authorization: bearer generated_token

在调用您的云函数时使用上面的授权密钥

Use above Authorization key while calling your cloud function

注意:

  1. 永远不要让所有用户都可以使用云功能

这篇关于Firebase云功能“您的客户端无权从此服务器获取URL/200"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆