When executing this code :
getToken(firebaseMessaging, { vapidKey: 'BFw3u4u17-GNyllfuz4DEyZmNou70YrK1mPQI5eGODChuj6qB3iEObAt3Z6O0b7eUTpyeJ4Ox2vaWittvDoKuTc' }).then((currentToken) => {
if (currentToken) {
console.log('FCM Token:', currentToken);
CurrentToken = currentToken;
console.log(firebaseApp);
console.log(firebaseMessaging);
sendTokenToServer(currentToken);
// يمكنك إرسال هذا الـ Token إلى الخادم لتسجيله
} else {
console.log('No registration token available. Request permission to generate one.');
}
}).catch((err) => {
console.log('An error occurred while retrieving token. ', err);
});
This error appears :
An error occurred while retrieving token. FirebaseError: Installations: Create Installation request failed with error "403 PERMISSION_DENIED: Requests to this API firebaseinstallations.googleapis method google.firebase.installations.v1.FirebaseInstallationsService.CreateInstallation are blocked." (installations/request-failed).
at getErrorFromResponse (common.ts:55:5)
at async createInstallationRequest (create-installation-request.ts:77:38)
at async registerInstallation (create-installation-request.ts:34:23)
at async completeInstallationRegistration (get-token.ts:40:63)
at async getToken$2 (get-token.ts:44:16)
at async getHeaders (requests.ts:160:5)
at async requestGetToken (requests.ts:47:13)
at async getNewToken (requests.ts:43:3)
When executing this code :
getToken(firebaseMessaging, { vapidKey: 'BFw3u4u17-GNyllfuz4DEyZmNou70YrK1mPQI5eGODChuj6qB3iEObAt3Z6O0b7eUTpyeJ4Ox2vaWittvDoKuTc' }).then((currentToken) => {
if (currentToken) {
console.log('FCM Token:', currentToken);
CurrentToken = currentToken;
console.log(firebaseApp);
console.log(firebaseMessaging);
sendTokenToServer(currentToken);
// يمكنك إرسال هذا الـ Token إلى الخادم لتسجيله
} else {
console.log('No registration token available. Request permission to generate one.');
}
}).catch((err) => {
console.log('An error occurred while retrieving token. ', err);
});
This error appears :
An error occurred while retrieving token. FirebaseError: Installations: Create Installation request failed with error "403 PERMISSION_DENIED: Requests to this API firebaseinstallations.googleapis.com method google.firebase.installations.v1.FirebaseInstallationsService.CreateInstallation are blocked." (installations/request-failed).
at getErrorFromResponse (common.ts:55:5)
at async createInstallationRequest (create-installation-request.ts:77:38)
at async registerInstallation (create-installation-request.ts:34:23)
at async completeInstallationRegistration (get-token.ts:40:63)
at async getToken$2 (get-token.ts:44:16)
at async getHeaders (requests.ts:160:5)
at async requestGetToken (requests.ts:47:13)
at async getNewToken (requests.ts:43:3)
The key you've been using has expired.
Solution: Log in to Firebase and generate a new key.