【问题标题】:Use the Google Cloud Compute Engine REST API from Firebase Cloud Functions使用 Firebase Cloud Functions 中的 Google Cloud Compute Engine REST API
【发布时间】:2019-12-30 03:57:40
【问题描述】:

我正在尝试使用 Firebase Functions 中的 Google Cloud Compute Engine REST API。 但是我不知道如何开始,因为我不知道如何从 Cloud Functions 进行身份验证。

This 是我找到的唯一资源,但我不知道如何让它在 Cloud Functions 上运行。

【问题讨论】:

  • 想通了。我真的很难找到身份验证部分。但现在明白了(见我的回答)

标签: node.js google-cloud-platform google-cloud-functions google-compute-engine


【解决方案1】:

我想通了。以下是从 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
})

【讨论】:

    猜你喜欢
    • 2020-03-15
    • 2023-04-07
    • 2020-12-23
    • 1970-01-01
    • 2017-12-19
    • 1970-01-01
    • 2021-10-23
    • 1970-01-01
    • 2021-02-04
    相关资源
    最近更新 更多