Skip to content

[firebase_messaging] Failed to get FIS auth token #3163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lizhuoyuan opened this issue Aug 12, 2020 · 11 comments · Fixed by #4012
Closed

[firebase_messaging] Failed to get FIS auth token #3163

lizhuoyuan opened this issue Aug 12, 2020 · 11 comments · Fixed by #4012

Comments

@lizhuoyuan
Copy link

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.

@iTEEECH
Copy link

iTEEECH commented Aug 17, 2020

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

@bartekpacia
Copy link

same error, nothing seems to help

@zmeggyesi
Copy link

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.

@mdmahendri
Copy link

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

@Cge001
Copy link

Cge001 commented Sep 25, 2020

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 ?? '';
});

@cuongvue
Copy link

I resolve this issue by turn on wifi connection

@bartekpacia
Copy link

any fixes?

@ikju
Copy link

ikju commented Oct 14, 2020

cuongvue Thanks! I solved as like you!

@dhnshri
Copy link

dhnshri commented Nov 1, 2020

I resolve this issue by turn on wifi connection

cuongvue Thank You . I solved as like you .

@Raziel422
Copy link

Raziel422 commented Nov 16, 2020

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.

@firebase firebase locked and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.