首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Firebase Cloud Functions中的Google Cloud Compute Engine REST API

使用Firebase Cloud Functions中的Google Cloud Compute Engine REST API
EN

Stack Overflow用户
提问于 2019-08-26 05:15:04
回答 1查看 233关注 0票数 0

我正在尝试使用Firebase函数中的Google Cloud Compute Engine REST API。然而,我被如何开始卡住了,因为我不知道如何从Cloud Functions进行身份验证。

This是我找到的唯一资源,但我不知道如何让它在云函数上工作。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-26 07:46:24

我想通了。以下是如何从云函数发送REST API调用:

代码语言:javascript
复制
const {auth} = require('google-auth-library');
const client = await auth.getClient({
  scopes: 'https://www.googleapis.com/auth/cloud-platform'
});

var url = [REQUEST URL HERE]
var data = {[REQUEST BODY HERE]}

response = await client.request({
  url: url,
  method: 'post',
  data: data
})
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57649775

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档