Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从Google函数访问Firestore-从插件获取元数据失败,错误为:无法刷新访问令牌_Javascript_Node.js_Google Cloud Firestore_Google Cloud Functions_Firebase Admin - Fatal编程技术网

Javascript 从Google函数访问Firestore-从插件获取元数据失败,错误为:无法刷新访问令牌

Javascript 从Google函数访问Firestore-从插件获取元数据失败,错误为:无法刷新访问令牌,javascript,node.js,google-cloud-firestore,google-cloud-functions,firebase-admin,Javascript,Node.js,Google Cloud Firestore,Google Cloud Functions,Firebase Admin,我正在部署一个google函数,它在同一个项目中执行一些服务器计算并将结果写入Firestore数据库 我遵循how-tos并通过 const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(); 并通过以下方式访问Firestore数据库: admin.firestore().collection('COLLECTION_NAME')

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

我遵循how-tos并通过

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
并通过以下方式访问Firestore数据库:

admin.firestore().collection('COLLECTION_NAME').add({data: value});
IAM用户...@gcf-admin-robot.IAM.gserviceaccount.com具有分配的Google云功能服务代理的角色

我得到以下错误:

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'

我做错了什么?

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

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

其中包括“projectname”@appspot.gserviceaccount.com 重新激活它解决了我的问题

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