配置文件为:
import firebase from 'firebase';
import * as admin from 'firebase-admin';
const config = {
apiKey: "XX",
authDomain: "XX",
databaseURL: "XX",
projectId: "XX",
storageBucket: "XX",
messagingSenderId: "XX",
appId: "XX"
};
const Admin_config ={
"type": "service_account",
"project_id": "XX",
"private_key_id": "XX",
"private_key": XX,
"client_email": "XX",
"client_id": "XX",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "XX"
}
admin.initializeApp({
credential:admin.credential.cert(Admin_config) ,
databaseURL: config.databaseURL
});
firebase.initializeApp(config);
export {firebase, admin};
我要删除用户的文件,导入管理员和firebase配置:
从'../config/fbconfig'导入{firebase,admin};
deleteAdmin = (adminDetail) => {
let uid = ""+adminDetail.UID
console.log(uid) //I'm getting proper UID here
admin.auth().deleteUser(uid)
.then(function() {
console.log('Successfully deleted user');
})
.catch(function(error) {
console.log('Error deleting user:', error);
});
}
我得到的错误是
Error deleting user: Error: Error while making request: incorrect header check. Error code: Z_DATA_ERROR
at FirebaseAppError.FirebaseError [as constructor] (error.js:58)
at FirebaseAppError.PrefixedFirebaseError [as constructor] (error.js:115)
at new FirebaseAppError (error.js:160)
at api-request.js:162
我无法通过这种方式删除用户。请帮忙。
答案 0 :(得分:0)
admin
.auth()
.deleteUser(uid)
.then(() => {
console.log('Successfully deleted user');
})
.catch((error) => {
console.log('Error deleting user:', error);
});
有关文档,请参阅 this。