[英]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.