title: Firebase Cloud Messaging : Request is missing required Authentication Credentials
body: <p>I'm struggling to get Firebase Cloud Messaging sdk to work with Nuxt JS</p>
  <p>I keep getting &quot; An error occurred while retrieving token.  FirebaseError: Messaging: A problem occured while subscribing the user to FCM: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. &quot;</p>
  <p>This is my code in the fcm.js which I'm running as a plugin in nuxt.config.js</p>
  <pre><code>import firebase from &quot;../firebase/init&quot;;
  
  firebase
    .messaging()
    .usePublicVapidKey(
      &quot;BDYE2EYHdIp8qHjTKcJYPvO4PgaAH2pSruP55FOtNs5jWsgdeg7YK6OgJ0daSu21kN7aSzU19NRXRqC4bfITZYQ &quot;
    );
  
  firebase
    .messaging()
    .getToken()
    .then((currentToken) =&gt; {
      console.log(currentToken);
      if (currentToken) {
        sendTokenToServer(currentToken);
        updateUIForPushEnabled(currentToken);
      } else {
        // Show permission request.
        console.log(
          &quot;No Instance ID token available. Request permission to generate one.&quot;
        );
        // Show permission UI.
        updateUIForPushPermissionRequired();
        setTokenSentToServer(false);
      }
    })
    .catch((err) =&gt; {
      console.log(&quot;An error occurred while retrieving token. &quot;, err);
      showToken(&quot;Error retrieving Instance ID token. &quot;, err);
      setTokenSentToServer(false);
    });
  
  </code></pre>
  <p>At the same time, if you are wondering if the user is authenticated. The user is definitely authenticated because I am able to access firestore data and access routes in my pages that I've guarded and I can see the UID details in my vuex store. So that side has no issue. I've also tried removing the usePublicVapidKey() line and it also doesn't work.</p>
  <p>Thank you.</p>