title: Firebase Error: Auth error from APNS or Web Push Service
body: <p>After running the following line in node-js:</p>
  
  <pre><code>import * as admin from "firebase-admin";
  import * as serviceAccount from "../../firebase_service_account_key.json";
  
  const app = admin.initializeApp({
    credential: admin.credential.cert(serviceAccount as any),
    databaseURL: "https://my-app-path.firebaseio.com"
  });
  
  admin.messaging().send({
      token: "known-good-token",
      notification: {
          title: "Test Push Note",
          body: "Here is some text"
      }
  });
  </code></pre>
  
  <p>I'm getting the error:</p>
  
  <pre><code>Error: Auth error from APNS or Web Push Service 
  Raw server response: 
  "{
    "error":{
      "code":401,
      "message":"Auth error from APNS or Web Push Service",
      "status":"UNAUTHENTICATED",
      "details"[
        {
          "@type":"type.googleapis.com/google.firebase.fcm.v1.FcmError",
          "errorCode":"THIRD_PARTY_AUTH_ERROR"
        },
        {
          "@type":"type.googleapis.com/google.firebase.fcm.v1.ApnsError",
          "statusCode":403,
          "reason":"InvalidProviderToken"
        }
      ]
    }
  }"
  </code></pre>
  
  <p>I've added an "APNs Authentication Key" to my ios project under the Settings > Cloud Messaging section of Firebase.  I've also properly downloaded and imported my service account json file.</p>
  
  <p>In terms of research, I've tried looking up the errors.  </p>
  
  <ul>
  <li><p>For the <code>InvalidProviderToken</code> error, <a href="https://stackoverflow.com/questions/42549421/ios-sending-push-with-apns-auth-key-suddenly-403-forbidden-reasoninvalid">this answer</a> seems to indicate I'm using an old token.  This is totally possible, but the logs on my app and database appear to match, so it seems off.</p></li>
  <li><p>As for the <code>THIRD_PARTY_AUTH_ERROR</code>, google gave me no hits.  The closest thing I found was <a href="https://firebase.google.com/docs/reference/node/firebase.auth.Error" rel="noreferrer">this</a>, and the following text might be the culprit (EDIT: it's not the issue):</p></li>
  </ul>
  
  <blockquote>
    <p>auth/unauthorized-domain</p>
    
    <p>Thrown if the app domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.</p>
  </blockquote>
  
  <p><strong>Does anyone have anymore details on this error which might help me get to the bottom of it?</strong></p>