使用Google API的Firebase – 需要帐单和/或身份validation
目标
使用免费的Firebase Spark计划 ,在Firebase云端function中使用googleapis 。
上下文
我已经将以下云端function代码部署到了我的Firebase项目中。 helloWorld端点按预期工作。
urlShortener端点返回两个错误:
Error: Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup...
和
Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions
题
如果我发送一个validation的请求,这是否certificate了这两个错误?
或者,googleapis以某种方式被视为External network
并且必须解决这两个错误,例如,打开结算以使用googleapis?
码
const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); const googleapis = require('googleapis'); const googleauth = require('google-auth-library'); var urlshortener = googleapis.urlshortener('v1'); exports.helloWorld = functions.https.onRequest((request, response) => { response.send("Hello from Firebase!"); }); var params = { shortUrl: 'short.url' //fake url for this comment }; // get the long url of a shortened url exports.urlShortener = functions.https.onRequest((request, response) => { urlshortener.url.get(params, function (err, response) { if (err) { console.log('Encountered error', err); } else { console.log('Long url is', response.longUrl); response.send("LongURL: ", response.longUrl); } }); });