title: java.io.IOException: AUTHENTICATION_FAILED in Android Firebase (and SERVICE_NOT_AVAILABLE)
body: <p>I'm getting following error on some devices while fetching firebase token:</p>
  <pre><code>Fatal Exception: d.b.a.b.g.f
  java.io.IOException: AUTHENTICATION_FAILED
  com.google.android.gms.tasks.zzu.getResult (zzu.java:15)
  MainActivity$3.onComplete (MainActivity.java:387)
  
  Caused by java.io.IOException
      AUTHENTICATION_FAILED
      com.google.firebase.iid.zzu.then (zzu.java:16)
      com.google.android.gms.tasks.zzd.run (zzd.java:5)
      java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
      java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
      com.google.android.gms.common.util.concurrent.zza.run (zza.java:6)
      java.lang.Thread.run (Thread.java:784)
  </code></pre>
  <p>Error log from Developer Console:</p>
  <pre><code>com.google.android.gms.tasks.RuntimeExecutionException: 
    at com.google.android.gms.tasks.zzu.getResult (zzu.java:15)
    at com.example.MainActivity$3.onComplete (MainActivity.java:387)
    at com.google.android.gms.tasks.zzj.run (zzj.java:4)
    at android.os.Handler.handleCallback (Handler.java:808)
    at android.os.Handler.dispatchMessage (Handler.java:101)
    at android.os.Looper.loop (Looper.java:166)
    at android.app.ActivityThread.main (ActivityThread.java:7529)
    at java.lang.reflect.Method.invoke (Method.java)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)
  Caused by: java.io.IOException: 
    at com.google.firebase.iid.zzu.then (zzu.java:16)
    at com.google.android.gms.tasks.zzd.run (zzd.java:5)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
    at com.google.android.gms.common.util.concurrent.zza.run (zza.java:6)
    at java.lang.Thread.run (Thread.java:784)
  </code></pre>
  <p>Here is the code which is responsible to fetch firebase token:</p>
  <pre><code>FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener&lt;InstanceIdResult&gt;() {
              @Override
              public void onComplete(@NonNull Task&lt;InstanceIdResult&gt; task) {
                  if (task.getResult() != null &amp;&amp; task.isSuccessful()) {
                      String firebaseToken = task.getResult().getToken();
                  }
              }
          });
  </code></pre>
  <p>I'm using following gradle dependencies.</p>
  <pre><code>implementation 'com.google.firebase:firebase-analytics:17.4.3'
  implementation 'com.google.firebase:firebase-crashlytics:17.0.1'
  implementation 'com.google.firebase:firebase-messaging:20.2.0'
  </code></pre>
  <p>I found similar <a href="https://stackoverflow.com/questions/56149754/how-to-solve-token-retrieval-failed-authentication-failed">questions and problems</a> but no conclusive answer. Some suggest it may be result of broken internet connection but my app needs authenticate before entering the app so internet is available. Is there anybody encountered same issue? Best regards.
  <a href="https://i.stack.imgur.com/6RrEY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6RrEY.png" alt="enter image description here" /></a></p>