我有一个App项目。
我也有一个谷歌云功能。
我想从App项目中调用Google函数。我只是不能让它起作用。
是的,如果我使函数完全公开(即将云函数设置为“允许所有通信量”,并为“allUsers”创建一个允许调用该函数的规则),它就能工作。但是如果我限制这两种设置中的任何一种,它就会立即停止工作,我得到403。
应用程序和函数在同一个项目中,所以我至少假设将函数设置为‘只允许内部通信’应该工作得很好,前提是我有一条关于“allUsers”的规则允许调用该函数。
这是如何工作的呢?人们通常如何从中调用(非公开的) Google函数?
发布于 2020-08-31 13:38:57
@GAEfan是正确的。
作为补充:我使用了官方的Google库来给我提供必要的标题。
const {GoogleAuth} = require('google-auth-library');
// Instead of specifying the type of client you'd like to use (JWT, OAuth2, etc)
// this library will automatically choose the right client based on the environment.
const googleCloudFunctionURL = 'https://europe-west1-project.cloudfunctions.net/function';
(async function() {
const auth = new GoogleAuth();
let googleCloudFunctionClient = await auth.getIdTokenClient(googleCloudFunctionURL);
console.log(await googleCloudFunctionClient.getRequestHeaders(googleCloudFunctionURL));
})();https://stackoverflow.com/questions/63634151
复制相似问题