如何解决从 Cloud Functions 请求预测的权限被拒绝
我在 Google Cloud AI Platform 上部署了一个模型 (TensorFlow),并在通过 Firebase 帐户部署 node.js 后尝试从 Cloud Function 获得预测。错误说:
Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging Details: Permission denied on resource project skinskanproject-capstone.
这里是日志的详细信息:
Error: Permission denied on resource project skinskanproject-capstone. at Gaxios._request (/workspace/node_modules/gaxios/build/src/gaxios.js:127:23) at processticksAndRejections (internal/process/task_queues.js:97:5) at async Compute.requestAsync (/workspace/node_modules/google-auth-library/build/src/auth/oauth2client.js:343:18) at async /workspace/lib/index.js:26:19
这是 node.js 代码:
import * as functions from 'firebase-functions';
import { google } from 'googleapis';
const ml = google.ml('v1')
export const predictCancer = functions.https.onRequest(async (request,response) => {
const instances = request.body.instances;
const model = request.body.model;
const { credential } = await google.auth.getApplicationDefault();
const modelName = `projects/skinskanproject-capstone/models/${model}`;
const preds = await ml.projects.predict({
auth: credential,name: modelName,requestBody: {
instances
}
} as any);
response.send(JSON.stringify(preds.data))
});
是否遗漏了任何 IAM 设置或身份验证步骤?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。