简体   繁体   中英

Getting a FirebaseException ( [ Invalid authority field:[http: ] ) when trying to use FireBaseAuth on the Firebase Local Emulator

I have an Android flutter app that I have connected to flutter and have setup the Firebase config successfully, and I have set it up to connect to a local Firebase emulators.

Emulators Enabled:

  • Firestore: working fine. I can query documents
  • Authentication: Getting an exception: [ Invalid authority field:[http: ]

Full error log:

I/flutter ( 8905): [firebase_auth/unknown] com.google.firebase.FirebaseException: An internal error has occurred. [ Invalid authority field:[http: ]
 firebase_core: ^1.4.0
 firebase_auth: ^3.0.0
 cloud_firestore: ^2.4.0
 google_sign_in: ^5.0.4

FirebaseAuth emulator at: 10.0.2.2:9099

My project's config in Firebase is also set up (Sha1 keys are set, etc). I'm trying to login using Google Sing In. What other config might I be missing that is causing the exception?

For Emulator: remove "http://" from firebaseAuth url, use only ip like "10.0.2.2" and port

检查您的 HTTP 链接并重新写入

In previous versions of Firebase Auth plugin, we used to write the port information in the url itself like

var url = 'http://localhost:9099';
// and then call useAuthEmulator like below
await FirebaseAuth.instance.useAuthEmulator(url);

but in later versions of Firebase Auth , the useAuthEmulator function was changed to accept the domain and port separately. Now its like below.

var url = 'localhost'; // Note you don't have to mention the protocol http or https
var port = 9099;
// and then call useAuthEmulator like below
await FirebaseAuth.instance.useAuthEmulator(url,port);

It seems like you were using an earlier version of Firebase Auth plugin, and then did a pub upgrade , thus, you changed to the second form shown above. But most probably, you might have forgotten to remove the protocol or port from the url .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM