Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 如何在google云功能中验证经过身份验证的用户?_Google Cloud Platform_Google Cloud Functions_Google Identity - Fatal编程技术网

Google cloud platform 如何在google云功能中验证经过身份验证的用户?

Google cloud platform 如何在google云功能中验证经过身份验证的用户?,google-cloud-platform,google-cloud-functions,google-identity,Google Cloud Platform,Google Cloud Functions,Google Identity,我正试图在我的谷歌云功能中使用谷歌的身份平台。我找不到任何关于它的信息。我想我应该可以做这样的事情: exports.helloWorld = (req, res) => { var user = getAuthenticatedUser(); //I made up this function and I'm imagining there's some API from google to do this. if ( user === undefined ) {

我正试图在我的谷歌云功能中使用谷歌的身份平台。我找不到任何关于它的信息。我想我应该可以做这样的事情:

exports.helloWorld = (req, res) => {

   var user = getAuthenticatedUser(); //I made up this function and I'm imagining there's some API from google to do this.

   if ( user === undefined ) {
     res.status(403).send('Forbidden!');
   }

   let message = req.query.message || req.body.message || 'Hello ' + user;
  res.status(200).send(message);
};
有人能告诉我正确的文件吗?我觉得我好像在兜圈子,没能确定这是怎么做的,还是应该怎么做


谢谢

基于您明确的用例,我相信您正在寻找的是:

您可以按照指南(仍处于测试阶段)确保您的函数仅由经过身份验证的用户运行

简而言之,这两个选项是使用OAuth 2.0客户端ID进行Google登录,该ID将在函数运行之前“自行”进行身份验证(节省您的成本)。另一个是Firebase,它在函数中进行身份验证,这意味着您将为未经身份验证的请求收取费用

请让我知道这是否有用:)

作为承诺,我的文章

您有启动代理和执行身份验证的基础,因为直接进行身份验证是不可能的。在本文中,身份验证使用API密钥,但您可以使用plug->它与云标识平台是同一平台


希望这有帮助

你使用私有云功能吗?而且您不想只授权经过身份验证的用户访问它,也不想授权未在您的项目中注册的用户或任何外部用户。我说得对吗?我的目标是让用户使用谷歌的身份平台登录(这允许使用电子邮件/密码注册或使用facebook、谷歌、linkedIn等社交登录)。只有通过该平台(在我的项目中有配置)进行身份验证的用户才能调用我的函数。我希望这能澄清这一点。谢谢简短的回答:你不能。但我正在写一篇关于云端点以及如何使用API密钥保护访问的文章。但Firebase Auth也有一个条件。你可以自己试试。我标记这个问题,我将在我的文章发布时更新回复,我将使用firebase auth为您提供一个特例(它与CIP完全相同)