firebaseflutter-websocial-authentication

Flutter Firebase Google Auth doesn't work in production


I'm trying to get my Flutter Web app to work with Firebase Google Auth. Everything works locally, but on the production server (hosted on Firebase) I just get the following not helpful stack trace:

js_helper.dart:1111 Uncaught 
b @ js_helper.dart:1111
$0 @ async_patch.dart:710
auu @ schedule_microtask.dart:40
auO @ schedule_microtask.dart:49
$1 @ async_patch.dart:49
awf @ js_helper.dart:1807
(anonymous) @ js_helper.dart:1839
childList (async)
$1 @ async_patch.dart:62
ail @ async_patch.dart:27
a8H @ zone.dart:1495
ii @ zone.dart:1707
pJ @ future_impl.dart:665
el @ future_impl.dart:50
nS @ future_impl.dart:33
hN @ future_impl.dart:21
$1 @ google_sign_in_web.dart:111
ar8 @ js_helper.dart:836
afa @ core_patch.dart:84
atA @ js_patch.dart:542
(anonymous) @ js_patch.dart:520
e.Zn @ cb=gapi.loaded_0:231
gk @ cb=gapi.loaded_0:234
bk @ cb=gapi.loaded_0:234
_.Mj.Vt @ cb=gapi.loaded_0:233
Kj @ cb=gapi.loaded_0:226
Promise.then (async)
Fj @ cb=gapi.loaded_0:226
_.Jj @ cb=gapi.loaded_0:226
ck @ cb=gapi.loaded_0:233
Lj @ cb=gapi.loaded_0:232
(anonymous) @ cb=gapi.loaded_0:227
(anonymous) @ cb=gapi.loaded_0:352
$u.dispatchEvent @ cb=gapi.loaded_0:262
_.Wv.Pv @ cb=gapi.loaded_0:297
(anonymous) @ cb=gapi.loaded_0:289
_.h.LY @ cb=gapi.loaded_0:284
(anonymous) @ cb=gapi.loaded_0:286

This is a brand new project with the latest Flutter / Firebase dependencies. My index html looks like this:

...
<head>
   <meta name="google-signin-client_id" content="myActualId.apps.googleusercontent.com">
</head>
<body>
   <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>
   <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-auth.js"></script>

I also added the domain I'm using in the Firebase console "Sign-in method" under "Authorised Domains". What can I do to debug this issue?


Solution

  • It turns out that Firefox is better in terms of reporting this issue. In contrast to the Chrome console, Firefox console produced a nice error message (unfortunately I haven't copied the exact message), telling me that the client ID was not registered with Google Cloud Services. There must be a synchronization issue between Firebase Console (where the ID was registered) and Google Cloud Console (where the ID was not registered).