FirebaseExtended / angularfire

AngularJS bindings for Firebase
MIT License
2.73k stars 630 forks source link

"This domain is not authorized" but I haven't done anything with auth. #778

Closed katowulf closed 3 years ago

katowulf commented 8 years ago

After following setup instructions at https://firebase.google.com/docs/database/, and then adding angularfire, I get this error:

firebase.js:71 Uncaught Error: This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.

However, I haven't even accessed $firebaseAuth. Likely related to recent changed by @davideast. Investigate.

Repro here: https://plnkr.co/edit/9fDwkAuOc0nNR6SDa3Xa?p=preview

iRoachie commented 8 years ago

Did you add plunker as an authorized domain in the firebase console?

It's Auth > Sign in method > OAuth redirect domains

katowulf commented 8 years ago

Shouldn't need to. I'm not using auth. That would be a workaround, however.

iRoachie commented 8 years ago

Okay I figured it out. You don't have to be using the auth service. In the firebase.initializeApp the key authDomain seems to check permissions for the current domain. If you remove that property then they'll be no errors. i think this confirms and explains the behaviour.

katowulf commented 8 years ago

Either this is an SDK problem, a docs problem, or an AngularFire problem. We should investigate which and then get it fixed. Since I didn't have time to determine which, and didn't see any internal bugs with the SDK, I dropped it here to investigate.

iRoachie commented 8 years ago

@katowulf It has nothing do with angularfire. Read my other comment.

To even take it a bit further I removed all instances of angularfire from your plunkr. And the error still shows.

var app = angular.module('app', ['firebase']);

app.run(function() {
  firebase.initializeApp({
    apiKey: "AIzaSyCktxUp-JovGV7Sw7dT9defEV-VwdmGe8E",
    authDomain: "kato-sandbox.firebaseapp.com",
    databaseURL: "https://kato-sandbox.firebaseio.com",
    storageBucket: "firebase-kato-sandbox.appspot.com",
  });
});

app.controller('ctrl', function($scope) {
  // var ref = firebase.database().ref('books');
  // $scope.raw = $firebaseArray(ref);
});

The error is gone when you remove the authDomain property;

var app = angular.module('app', ['firebase']);

app.run(function() {
  firebase.initializeApp({
    apiKey: "AIzaSyCktxUp-JovGV7Sw7dT9defEV-VwdmGe8E",
    databaseURL: "https://kato-sandbox.firebaseio.com",
    storageBucket: "firebase-kato-sandbox.appspot.com",
  });
});

app.controller('ctrl', function($scope) {
  // var ref = firebase.database().ref('books');
  // $scope.raw = $firebaseArray(ref);
});
matheushf commented 8 years ago

It also happened to me, you need to remove the authDomain: "kato-sandbox.firebaseapp.com" or you add plunker to OAuth redirect domains, like @iRoachie said

jwngr commented 8 years ago

Kato has a very fair point here. If you are not doing anything auth-related on a domain you do not have listed in your authorized domains, it should not throw any errors. This seems like a bad getting started experience. I'm not sure if this is an AngularFire or a Firebase problem either but is should be easy enough to determine.

jamesdaniels commented 3 years ago

Closing as stale.