Firebase Functions CLI中的Firebase Admin SDK-获取访问令牌时出错

Firebase Functions CLI中的Firebase Admin SDK-获取访问令牌时出错,firebase,authentication,google-cloud-firestore,google-cloud-functions,Firebase,Authentication,Google Cloud Firestore,Google Cloud Functions,我正在尝试使用firebase admin sdk手动更新用户密码,其想法是通过在firestore中创建新文档(显然使用正确的规则)来使用onCreate触发器来实现这一点 根据firebase文档,我不需要使用除此之外的任何东西来从我的firebase功能环境中进行自动验证: const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp

我正在尝试使用firebase admin sdk手动更新用户密码,其想法是通过在firestore中创建新文档(显然使用正确的规则)来使用onCreate触发器来实现这一点

根据firebase文档,我不需要使用除此之外的任何东西来从我的firebase功能环境中进行自动验证:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
为了测试该功能,我刚刚从firestore的firebase控制台ui手动添加了文档,正如我所看到的,触发器正在执行它的工作,问题在于使用firebase admin sdk更新用户密码时

我将从日志中获得下一条错误消息:

更新用户时出错:{错误:为提供了凭据实现 通过“credential”属性初始化EAPP()无法获取有效的 Google OAuth2访问令牌出现以下错误:“获取错误 访问令牌

如果您想了解firebase云功能的实现方式,请参阅以下内容:

'use strict';

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

triggerNewDocument();

function triggerNewDocument() {
  exports.updateUserData = functions.firestore
    .document('updateUserPasswords/{userId}')
    .onCreate((snap, context) => {
      // Get an object representing the document
      // e.g. {'name': 'Marie', 'age': 66}
      const newValue = snap.data();
      console.log(newValue);

      // access a particular field as you would any JS property
      const uid = newValue.uid;
      const newPassword = newValue.password;
      return updateUserPassword(uid, newPassword);
      // perform desired operations ...
    });
}

function updateUserPassword(uid, newPassword) {
  admin.auth().updateUser(uid, {
    password: newPassword,
  })
    .then(function(userRecord) {
      // See the UserRecord reference doc for the contents of userRecord.
      return userRecord.toJSON();
    })
    .catch(function(error) {
      return error;
    });
}

这里有什么我可能遗漏的吗?提前感谢您提供的任何提示或帮助。

整个问题不知何故是由admin sdk自动生成的服务帐户处于非活动状态

无论如何,我必须禁用和启用服务帐户至少3次,以使其工作,希望这可以有助于任何人有相同的问题

一个简单的错误