title: com.google.firebase.auth.FirebaseAuthException: Token is not for this app
body: <p>I'm trying to generate custom token in server then verifying it. I would like to reuse Firebase authentication token across my app for api security.</p>
  
  <p>Just for testing I have this code which I get from Firebase docs. <a href="https://firebase.google.com/docs/auth/admin/create-custom-tokens" rel="nofollow noreferrer">Creating Custom Token</a>, <a href="https://firebase.google.com/docs/auth/admin/verify-id-tokens" rel="nofollow noreferrer">Verifying ID Token</a></p>
  
  <pre><code>FirebaseOptions options = new FirebaseOptions.Builder()
          .setServiceAccount(sce.getServletContext().getResourceAsStream("/WEB-INF/serviceAccountKey.json"))
          .setDatabaseUrl("https://[project-id].firebaseio.com/")
          .build();
  
  FirebaseApp.initializeApp(options);
  
  final AtomicBoolean done = new AtomicBoolean(false);
  
  FirebaseAuth.getInstance().createCustomToken("the-great-uid")
          .addOnSuccessListener(new OnSuccessListener&lt;String&gt;() {
              @Override
              public void onSuccess(String customToken) {
  
                  FirebaseAuth.getInstance().verifyIdToken(customToken)
                          .addOnFailureListener(new OnFailureListener() {
                              @Override
                              public void onFailure(Exception excptn) {
                                  LOG.log(Level.SEVERE, "fail verification", excptn);
                                  done.set(true);
                              }
                          })
                          .addOnSuccessListener(new OnSuccessListener&lt;FirebaseToken&gt;() {
                              @Override
                              public void onSuccess(FirebaseToken decodedToken) {
                                  String uid = decodedToken.getUid();
                                  LOG.log(Level.INFO, "SUCCESS VERIFICATION: ");
                                  LOG.log(Level.INFO, "UUDI: {0}", uid);
                                  done.set(true);
                              }
  
                          });
  
                  LOG.log(Level.INFO, "Custom token: {0}", customToken);
                  done.set(true);
              }
          });
  
  while (!done.get());
  </code></pre>
  
  <p>What Im getting:</p>
  
  <pre><code>[INFO] INFO: Custom token: eyJhbGciOiJSUzI1NiJ9.eyJ******
  [INFO] After custom token
  [INFO] Nov 17, 2016 3:15:27 PM com.adslide.backend.listeners.AdslideContextListener$1$2 onFailure
  [INFO] com.google.firebase.auth.FirebaseAuthException: Token is not for this app
  [INFO]  at com.google.firebase.auth.internal.FirebaseTokenVerifier.verifyTokenAndSignature(FirebaseTokenVerifier.java:52)
  [INFO]  at com.google.firebase.auth.FirebaseAuth$1.call(FirebaseAuth.java:150)
  [INFO]  at com.google.firebase.auth.FirebaseAuth$1.call(FirebaseAuth.java:144)
  [INFO]  at com.google.firebase.tasks.Tasks$1.run(Tasks.java:63)
  [INFO]  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  [INFO]  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  [INFO]  at com.google.appengine.tools.development.BackgroundThreadFactory$1$1.run(BackgroundThreadFactory.java:60)
  </code></pre>
  
  <p>Did I missed something? I am using Google Appengine.. Please assume I provided the correct <code>project-id</code> and <code>serviceAccountKey.json</code></p>