VueJS : Firebase throws error "FirebaseError: Messaging: A problem occurred while subscribing the user to FCM"

Viewed 1851

The below code receives a Firebase error: "FirebaseError: Messaging: A problem occurred while subscribing the user to FCM: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential".

It was working 2 months ago (I swear) but I kept it aside to take up some other work and today when I run it again, I see this error. Please let me know what I might be doing wrong. Appreciate your help.

// Initialize Firebase, below snippet copied from Firebase console
// Your web app's Firebase configuration
this.firebaseConfig = {
    apiKey: "<MY API KEY>",
    authDomain: "<name>.firebaseapp.com",
    databaseURL: "<URL>",
    projectId: "<ProjectID>",
    storageBucket: "<storage bucket>",
    messagingSenderId: "<sendid>",
    appId: "<appID>"
};

firebase.initializeApp(this.firebaseConfig);

// Call Firebase and get toke, n
firebase.messaging().usePublicVapidKey("<VAPIDKEY>");

firebase.messaging()
    .getToken()
    .then(function (token) {
        TokenElem.innerHTML = "token is : " + token;
    })
    .catch(function (err) {
        ErrElem.innerHTML = ErrElem.innerHTML + "; " + err
        console.log("Unable to get permission.", err);
    });
1 Answers

Make sure you have a valid VAPIDKEY refer the below link and check if this solves your issue. link here

I found another article which might help you. Link here

Related