【发布时间】:2021-10-19 09:59:09
【问题描述】:
我在旧的谷歌计算引擎上有一个工作的 nodejs 应用程序。将应用程序迁移到新的计算引擎后,我进入了这一行:
const [files] = await storage.bucket(GOOGLE_CLOUD_PROJECT_ID_PUBLIC).getFiles();
以下异常:
Error: Could not refresh access token: A Not Found error was returned while attempting to retrieve an accesstoken for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have any permission scopes specified: Could not refresh access token:
at Gaxios._request (/smar/backend.smar.shop/node_modules/gaxios/build/src/gaxios.js:129:23)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async metadataAccessor (/smar/backend.smar.shop/node_modules/gcp-metadata/build/src/index.js:68:21)
at async Compute.refreshTokenNoCache (/smar/backend.smar.shop/node_modules/google-auth-library/build/src/auth/computeclient.js:53:20)
at async Compute.getRequestMetadataAsync (/smar/backend.smar.shop/node_modules/google-auth-library/build/src/auth/oauth2client.js:261:17)
at async Compute.getRequestHeaders (/smar/backend.smar.shop/node_modules/google-auth-library/build/src/auth/oauth2client.js:238:26)
at async GoogleAuth.authorizeRequest (/smar/backend.smar.shop/node_modules/google-auth-library/build/src/auth/googleauth.js:600:25)
at async Promise.all (index 1)
我想这里的重要部分是:因为 Compute Engine 实例没有指定任何权限范围
谁能解释一下这是什么意思,或者我可以在哪里找到这些权限范围?我是否必须修改 Compute Engine 的配置?
【问题讨论】:
-
编辑范围,菜单>计算引擎>VM实例>名称>停止实例>编辑>云API范围。
-
@danyL 我觉得有点傻。我已经停止了实例。但是在编辑模式下,我看不到任何有作用域的东西:screencast.com/t/pmUqCJ6b 我错过了权限吗?
-
编辑后转到 SAVE 按钮上方的访问范围 > 为每个 API 设置访问权限
-
@danyL 我爱你!
标签: google-cloud-platform google-cloud-storage google-compute-engine