首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Google Functions访问Firestore -从插件获取元数据失败,出现错误:无法刷新访问令牌

从Google Functions访问Firestore -从插件获取元数据失败,出现错误:无法刷新访问令牌
EN

Stack Overflow用户
提问于 2020-08-11 22:24:15
回答 2查看 374关注 0票数 0

我正在部署一个google函数,它执行一些服务器计算,并将结果写入同一项目的Firestore DB中。

我遵循how-tos并通过以下方式配置函数

代码语言:javascript
复制
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

并使用以下命令访问Firestore数据库:

代码语言:javascript
复制
admin.firestore().collection('COLLECTION_NAME').add({data: value});

IAM用户...@gcf-admin-robot.iam.gserviceaccount.com具有分配的Google Cloud Functions Service Agent角色。

我得到以下错误:

代码语言:javascript
复制
Error: 500 undefined: Getting metadata from plugin failed with error: Could not refresh access token: Unsuccessful response status code. Request failed with status code 500
     at Object.callErrorFromStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
     at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client.js:175:52)
     at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:341:141)
     at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:304:181)
     at Http2CallStream.outputStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:116:74)
     at Http2CallStream.maybeOutputStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:155:22)
     at Http2CallStream.endCall (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:141:18)
     at Http2CallStream.cancelWithStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:457:14)
     at callStream.filterStack.sendMetadata.then (/workspace/node_modules/@grpc/grpc-js/build/src/channel.js:225:36)
     at process._tickCallback (internal/process/next_tick.js:68:7)
 Caused by: Error
     at WriteBatch.commit (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:415:23)
     at DocumentReference.create (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:283:14)
     at CollectionReference.add (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:2011:28)
     at exports.parseProduct.functions.region.https.onRequest (/workspace/index.js:55:56)
     at process._tickCallback (internal/process/next_tick.js:68:7)
   code: '500',
   details:
    'Getting metadata from plugin failed with error: Could not refresh access token: Unsuccessful response status code. Request failed with status 
   metadata: Metadata { internalRepr: Map {}, options: {} },
   note:
    'Exception occurred in retry method that was not classified as transient'

我做错了什么?

EN

回答 2

Stack Overflow用户

发布于 2020-08-12 02:52:05

对于任何看到上述错误消息的人。它连接(至少在这种情况下)到服务帐户的权限。我正在调整一些权限,并停用了一些我认为不需要的帐户。

其中之一是“项目名称”@appspot.gserviceaccount.com重新激活它解决了我的问题。

如果Google能在这种情况下显示更多有意义的错误消息,那就太好了!

票数 1
EN

Stack Overflow用户

发布于 2020-08-12 01:54:56

这似乎是一个内部问题,而不是你正在做的事情。通过快速搜索,我在GitHubSO中发现了一个非常类似的问题。从这些链接中,我注意到它更多的是关于一个库,我建议联系Firebase Support,因为他们可以检查环境的内部,因为在幕后可能会发生一些奇怪的魔法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63360233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档