设置为/ item失败:permission_denied

时间:2016-10-07 16:10:13

标签: javascript angular firebase-realtime-database angularfire firebase-security

我跟踪了angular2 firebase的basic guide并得到了这个错误。为什么呢?

app.module.ts:

export const firebaseConfig = {
  apiKey: "...",
  authDomain: "....",
  databaseURL: "....",
  storageBucket: "...."
};

@NgModule({
  declarations: [
   ...
  ],

  imports: [
    ....,
    AngularFireModule.initializeApp(firebaseConfig)
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule{
}

app.component.ts:

export class AppComponent implements OnInit
{
  private item: FirebaseObjectObservable<any>;
  //
  constructor(private af: AngularFire){}
  //
  public ngOnInit(): void
  {
    this.item = this.item = this.af.database.object('/item');
  }
}

错误:

FIREBASE WARNING: Exception was thrown by user callback. Error: permission_denied at /item: Client doesn't have permission to access the desired data.
    at Error (native)
    at G (http://localhost:4200/main.bundle.js:77012:36)
    at Object.G (http://localhost:4200/main.bundle.js:77016:86)
    at http://localhost:4200/main.bundle.js:76989:503
    at nh.h.wd (http://localhost:4200/main.bundle.js:76994:104)
    at af.wd (http://localhost:4200/main.bundle.js:76897:364)
    at vd.hg (http://localhost:4200/main.bundle.js:76895:280)
    at yd (http://localhost:4200/main.bundle.js:76848:464)
    at bound WrappedWebSocket.La.onmessage (http://localhost:4200/main.bundle.js:76847:245)
    at bound WrappedWebSocket.wrapFn [as _onmessage] (http://localhost:4200/main.bundle.js:93544:29) 
error_handler.js:45 EXCEPTION: permission_denied at /item: Client doesn't have permission to access the desired data.ErrorHandler.handleError @ error_handler.js:45next @ application_ref.js:273schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64ZoneDelegate.handleError @ zone.js:207Zone.runTask @ zone.js:139ZoneTask.invoke @ zone.js:304
error_handler.js:50 ORIGINAL STACKTRACE:ErrorHandler.handleError @ error_handler.js:50next @ application_ref.js:273schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64ZoneDelegate.handleError @ zone.js:207Zone.runTask @ zone.js:139ZoneTask.invoke @ zone.js:304
error_handler.js:51 Error: permission_denied at /item: Client doesn't have permission to access the desired data.
    at Error (native)
    at G (http://localhost:4200/main.bundle.js:77012:36)
    at Object.G (http://localhost:4200/main.bundle.js:77016:86)
    at http://localhost:4200/main.bundle.js:76989:503
    at nh.h.wd (http://localhost:4200/main.bundle.js:76994:104)
    at af.wd (http://localhost:4200/main.bundle.js:76897:364)
    at vd.hg (http://localhost:4200/main.bundle.js:76895:280)
    at yd (http://localhost:4200/main.bundle.js:76848:464)
    at bound WrappedWebSocket.La.onmessage (http://localhost:4200/main.bundle.js:76847:245)
    at bound WrappedWebSocket.wrapFn [as _onmessage] (http://localhost:4200/main.bundle.js:93544:29)ErrorHandler.handleError @ error_handler.js:51next @ application_ref.js:273schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64ZoneDelegate.handleError @ zone.js:207Zone.runTask @ zone.js:139ZoneTask.invoke @ zone.js:304
firebase.js:450 Uncaught Error: permission_denied at /item: Client doesn't have permission to access the desired data.G @ firebase.js:450(anonymous function) @ firebase.js:454(anonymous function) @ firebase.js:427h.wd @ firebase.js:432af.wd @ firebase.js:335(anonymous function) @ firebase.js:333yd @ firebase.js:286La.onmessage @ firebase.js:285wrapFn @ zone.js:647ZoneDelegate.invokeTask @ zone.js:236onInvokeTask @ ng_zone_impl.js:34ZoneDelegate.invokeTask @ zone.js:235Zone.runTask @ zone.js:136ZoneTask.invoke @ zone.js:304

0 个答案:

没有答案