简体   繁体   English

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

[英]Use the Google Cloud Compute Engine REST API from Firebase Cloud Functions

I am trying to use the Google Cloud Compute Engine REST API from Firebase Functions. 我正在尝试使用Firebase Functions的Google Cloud Compute Engine REST API。 However I'm stuck with how to start, since I can't figure out how to authenticate from Cloud Functions. 但是,由于无法确定如何从Cloud Functions进行身份验证,因此我对如何开始感到困惑。

This is the only resource I have found, but I can't figure out how to get it working on Cloud Functions. 是我找到的唯一资源,但是我不知道如何在Cloud Functions上运行它。

I figured it out. 我想到了。 Here's how to send REST API calls from Cloud Functions: 以下是从Cloud Functions发送REST API调用的方法:

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
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 REST API 获取图像并将其上传到 Firebase 云存储使用 Z035489FF8D324159ZEEA 功能 Cloud Storage - Getting image from REST API and uploading it to Firebase Cloud Storage using Firebase Cloud Functions 为Google Compute Engine设置Cloud 9 - Setup Cloud 9 for Google Compute Engine 如何使用内部IP从Google Cloud Functions连接到我的Compute Engine MongoDB实例? - How to connect to my Compute Engine MongoDB instance from Google Cloud Functions using the internal IP? 使用Google People API和Firebase的云功能 - Using Google People API with Cloud Functions for Firebase Google Cloud Compute Engine API:直接使用setMetadata创建createVM - Google Cloud Compute Engine API: createVM directly with setMetadata 从Firebase提取数据-Google云功能 - Fetching data from Firebase - Google Cloud Functions Google Cloud Compute Engine-Node.js无法正常工作 - Google Cloud Compute Engine - Nodejs not working 从node-js app引擎到google云功能的路由 - 云功能与App Engine的集成 - Route from node-js app engine to google cloud functions - integration of cloud functions with App Engine Firebase 云功能找不到 woocommerce-rest-api package - Firebase cloud functions not finding woocommerce-rest-api package 使用Cloud Functions REST API请求将文件存储在Firebase存储中 - Store file in Firebase Storage using Cloud Functions REST API request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM