flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_messaging] Failed to get FIS auth token

Open lizhuoyuan opened this issue 6 years ago • 11 comments

Describe the bug Unable to obtain token To Reproduce Steps to reproduce the behavior: run app

Expected behavior get token

Additional context

  void getToken() async {
    String token = await _firebaseMessaging.getToken();
    print(token);
    setState(() {
      this.token = token;
    });
  }

Flutter doctor Run flutter doctor and paste the output below: 1.12 fix 8 and dev all like this

E/FirebaseInstanceId(23234): Failed to get FIS auth token
E/FirebaseInstanceId(23234): java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseInstanceId(23234): 	at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
E/FirebaseInstanceId(23234): 	at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.GmsRpc.setDefaultAttributesToBundle(com.google.firebase:firebase-iid@@20.2.3:55)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.GmsRpc.startRpc(com.google.firebase:firebase-iid@@20.2.3:37)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.GmsRpc.getToken(com.google.firebase:firebase-iid@@20.2.3:13)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId.lambda$getInstanceId$2$FirebaseInstanceId(com.google.firebase:firebase-iid@@20.2.3:164)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId$$Lambda$4.start(Unknown Source:8)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.RequestDeduplicator.getOrStartGetTokenRequest(com.google.firebase:firebase-iid@@20.2.3:14)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId.lambda$getInstanceId$3$FirebaseInstanceId(com.google.firebase:firebase-iid@@20.2.3:163)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId$$Lambda$1.then(Unknown Source:6)
E/FirebaseInstanceId(23234): 	at com.google.android.gms.tasks.zzf.run(Unknown Source:2)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/FirebaseInstanceId(23234): 	at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)
E/FirebaseInstanceId(23234): 	at java.lang.Thread.run(Thread.java:764)
E/FirebaseInstanceId(23234): Caused by: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.createFirebaseInstallation(FirebaseInstallationServiceClient.java:183)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations.registerFidWithServer(FirebaseInstallations.java:489)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:360)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationOrRefresh$2(FirebaseInstallations.java:350)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations$$Lambda$4.run(Unknown Source:4)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/FirebaseInstanceId(23234): 	... 1 more
W/FirebaseMessagingPlugin(23234): getToken, error fetching instanceID: 
W/FirebaseMessagingPlugin(23234): java.io.IOException: FIS_AUTH_ERROR
W/FirebaseMessagingPlugin(23234): 	at com.google.firebase.iid.GmsRpc.handleResponse(com.google.firebase:firebase-iid@@20.2.3:81)
W/FirebaseMessagingPlugin(23234): 	at com.google.firebase.iid.GmsRpc.lambda$extractResponseWhenComplete$0$GmsRpc(com.google.firebase:firebase-iid@@20.2.3:91)
W/FirebaseMessagingPlugin(23234): 	at com.google.firebase.iid.GmsRpc$$Lambda$0.then(Unknown Source:2)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.tasks.zzd.run(Unknown Source:5)
W/FirebaseMessagingPlugin(23234): 	at com.google.firebase.iid.FirebaseIidExecutors$$Lambda$0.execute(Unknown Source:0)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.tasks.zzc.onComplete(Unknown Source:6)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.tasks.zzr.zza(Unknown Source:19)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.tasks.zzu.setResult(Unknown Source:86)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.tasks.zzd.run(Unknown Source:15)
W/FirebaseMessagingPlugin(23234): 	at com.google.firebase.iid.FirebaseIidExecutors$$Lambda$0.execute(Unknown Source:0)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.tasks.zzc.onComplete(Unknown Source:6)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.tasks.zzr.zza(Unknown Source:19)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.tasks.zzu.setResult(Unknown Source:86)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.tasks.TaskCompletionSource.setResult(Unknown Source:8)
W/FirebaseMessagingPlugin(23234): 	at com.google.firebase.iid.MessengerIpcClient$Request.finish(com.google.firebase:firebase-iid@@20.2.3:20)
W/FirebaseMessagingPlugin(23234): 	at com.google.firebase.iid.MessengerIpcClient$TwoWayRequest.handleResponseInternal(com.google.firebase:firebase-iid@@20.2.3:7)
W/FirebaseMessagingPlugin(23234): 	at com.google.firebase.iid.MessengerIpcClient$Request.handleResponse(com.google.firebase:firebase-iid@@20.2.3:29)
W/FirebaseMessagingPlugin(23234): 	at com.google.firebase.iid.MessengerIpcClient$Connection.receivedResponse(com.google.firebase:firebase-iid@@20.2.3:42)
W/FirebaseMessagingPlugin(23234): 	at com.google.firebase.iid.MessengerIpcClient$Connection$$Lambda$0.handleMessage(Unknown Source:2)
W/FirebaseMessagingPlugin(23234): 	at android.os.Handler.dispatchMessage(Handler.java:102)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.internal.firebase-iid.zze.dispatchMessageTraced(com.google.firebase:firebase-iid@@20.2.3:21)
W/FirebaseMessagingPlugin(23234): 	at com.google.android.gms.internal.firebase-iid.zze.dispatchMessage(com.google.firebase:firebase-iid@@20.2.3:11)
W/FirebaseMessagingPlugin(23234): 	at android.os.Looper.loop(Looper.java:193)
W/FirebaseMessagingPlugin(23234): 	at android.app.ActivityThread.main(ActivityThread.java:6940)
W/FirebaseMessagingPlugin(23234): 	at java.lang.reflect.Method.invoke(Native Method)
W/FirebaseMessagingPlugin(23234): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
W/FirebaseMessagingPlugin(23234): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/flutter (23234): null
E/FirebaseInstanceId(23234): Failed to get FIS auth token
E/FirebaseInstanceId(23234): java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseInstanceId(23234): 	at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
E/FirebaseInstanceId(23234): 	at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.GmsRpc.setDefaultAttributesToBundle(com.google.firebase:firebase-iid@@20.2.3:55)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.GmsRpc.startRpc(com.google.firebase:firebase-iid@@20.2.3:37)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.GmsRpc.getToken(com.google.firebase:firebase-iid@@20.2.3:13)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId.lambda$getInstanceId$2$FirebaseInstanceId(com.google.firebase:firebase-iid@@20.2.3:164)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId$$Lambda$4.start(Unknown Source:8)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.RequestDeduplicator.getOrStartGetTokenRequest(com.google.firebase:firebase-iid@@20.2.3:14)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId.lambda$getInstanceId$3$FirebaseInstanceId(com.google.firebase:firebase-iid@@20.2.3:163)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId$$Lambda$1.then(Unknown Source:6)
E/FirebaseInstanceId(23234): 	at com.google.android.gms.tasks.zzf.run(Unknown Source:2)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/FirebaseInstanceId(23234): 	at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)
E/FirebaseInstanceId(23234): 	at java.lang.Thread.run(Thread.java:764)
E/FirebaseInstanceId(23234): Caused by: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.createFirebaseInstallation(FirebaseInstallationServiceClient.java:183)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations.registerFidWithServer(FirebaseInstallations.java:489)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:360)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationOrRefresh$2(FirebaseInstallations.java:350)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations$$Lambda$4.run(Unknown Source:4)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/FirebaseInstanceId(23234): 	... 1 more
E/Choreographer(23234): skip doframe for zy.li.flutterfcmexample
E/FirebaseInstanceId(23234): Topic sync or token retrieval failed on hard failure exceptions: FIS_AUTH_ERROR. Won't retry the operation.
E/FirebaseInstanceId(23234): Failed to get FIS auth token
E/FirebaseInstanceId(23234): java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseInstanceId(23234): 	at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
E/FirebaseInstanceId(23234): 	at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.GmsRpc.setDefaultAttributesToBundle(com.google.firebase:firebase-iid@@20.2.3:55)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.GmsRpc.startRpc(com.google.firebase:firebase-iid@@20.2.3:37)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.GmsRpc.getToken(com.google.firebase:firebase-iid@@20.2.3:13)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId.lambda$getInstanceId$2$FirebaseInstanceId(com.google.firebase:firebase-iid@@20.2.3:164)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId$$Lambda$4.start(Unknown Source:8)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.RequestDeduplicator.getOrStartGetTokenRequest(com.google.firebase:firebase-iid@@20.2.3:14)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId.lambda$getInstanceId$3$FirebaseInstanceId(com.google.firebase:firebase-iid@@20.2.3:163)
E/FirebaseInstanceId(23234): 	at com.google.firebase.iid.FirebaseInstanceId$$Lambda$1.then(Unknown Source:6)
E/FirebaseInstanceId(23234): 	at com.google.android.gms.tasks.zzf.run(Unknown Source:2)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/FirebaseInstanceId(23234): 	at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)
E/FirebaseInstanceId(23234): 	at java.lang.Thread.run(Thread.java:764)
E/FirebaseInstanceId(23234): Caused by: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.createFirebaseInstallation(FirebaseInstallationServiceClient.java:183)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations.registerFidWithServer(FirebaseInstallations.java:489)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:360)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationOrRefresh$2(FirebaseInstallations.java:350)
E/FirebaseInstanceId(23234): 	at com.google.firebase.installations.FirebaseInstallations$$Lambda$4.run(Unknown Source:4)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/FirebaseInstanceId(23234): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/FirebaseInstanceId(23234): 	... 1 more
E/FirebaseInstanceId(23234): Topic sync or token retrieval failed on hard failure exceptions: FIS_AUTH_ERROR. Won't retry the operation.

lizhuoyuan avatar Aug 12 '20 15:08 lizhuoyuan

got this https://stackoverflow.com/questions/61453640/android-error-when-communicating-with-the-firebase-installations-server-api

lizhuoyuan avatar Aug 13 '20 03:08 lizhuoyuan

try to check the AVD manager emulator, click on settings advanced and set Cold boot. It should work.

iTEEECH avatar Aug 17 '20 09:08 iTEEECH

same error, nothing seems to help

bartekpacia avatar Aug 19 '20 23:08 bartekpacia

Weird thing, I don't (explicitly) use Messaging, but I'm still getting this error on my test device. I do use

  • Storage
  • Admob
  • Auth
  • Crashlytics
  • Analytics
  • Remote Config

But the crash seems to be happening even before the first call of my main.dart is executed.

zmeggyesi avatar Aug 26 '20 12:08 zmeggyesi

i encounter this when changing my firebase project. flutter clean solves the problem

mahendrimd avatar Sep 21 '20 20:09 mahendrimd

i meet this problem. i try to solves it just like belowe:

old code:

Future setup() async { ... pushToken = await PushManager.getInstance().getToken(); ... }

Future getToken() async { try{ return await _firebaseMessaging.getToken(); } catch(error){ return ''; } }

new code:

init() async { getToken(); ... }

getToken() async { try{ AppSetting.instance.pushToken = await _firebaseMessaging.getToken(); } catch(error) { AppSetting.insatnce.pushToken = ''; } }

conclusion:the different of the two coding style is the getToken() method have a async return type。 if i use the old code,run it will get an exception, meanwhile my android phone and iphone stop on the start screen,and serval minutes later show the home page. i had try different methods to avoid the problem, and finally i test this method is ok... that is new code, and run the new code i will get an exception too, but app will did not stop on the start screen. it's ok.

and i had found anther method is ok too, like this:

String tokenStr; _firebaseMessaging.getToken().then((token) { tokenStr = token; }).timeout(Duration(seconds: 5), onTimeout: () { tokenStr = ''; }).catchError((error) { tokenStr = ''; }).whenComplete(() { AppSetting.instance.pushToken = tokenStr ?? ''; });

Cge001 avatar Sep 25 '20 09:09 Cge001

I resolve this issue by turn on wifi connection

cuongvue avatar Sep 26 '20 13:09 cuongvue

any fixes?

bartekpacia avatar Oct 06 '20 21:10 bartekpacia

cuongvue Thanks! I solved as like you!

ikju avatar Oct 14 '20 08:10 ikju

I resolve this issue by turn on wifi connection

cuongvue Thank You . I solved as like you .

dhnshri avatar Nov 01 '20 12:11 dhnshri

Hi, I had the same issue and in my case, my android emulator didn't have Google Play Services added. Created a new one with Google Play Services services and it worked.

Raziel422 avatar Nov 16 '20 08:11 Raziel422