Summary
This commit adjusted the way the project_id is used when FCMNotification is instantiated:
80fec94
We run a cloud function which does push notifications in a different project to the firebase project. The service account exists in a different project.
Details
We instantiate FCMNotification like this:
push_service = FCMNotification(
service_account_file=service_account_file,
project_id="firebase-project",
)
That project_id will never be used if you have a service account:
|
project_id = getattr(self.credentials, "project_id", None) or self._project_id |
Our service account is in a different project:
{
"type": "service_account",
"project_id": "backend-project",
"private_key_id": "<redacted>",
"private_key": "<redacted>",
"client_email": "<redacted>",
"client_id": "<redacted>",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/sepush-push-topics%40sepush-backend.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
Recommendation
Adjust this code:
|
project_id = getattr(self.credentials, "project_id", None) or self._project_id |
To be:
project_id = self._project_id or getattr(self.credentials, "project_id", None)
Summary
This commit adjusted the way the project_id is used when
FCMNotificationis instantiated:80fec94
We run a cloud function which does push notifications in a different project to the firebase project. The service account exists in a different project.
Details
We instantiate
FCMNotificationlike this:That project_id will never be used if you have a service account:
PyFCM/pyfcm/baseapi.py
Line 89 in c94dc6d
Our service account is in a different project:
{ "type": "service_account", "project_id": "backend-project", "private_key_id": "<redacted>", "private_key": "<redacted>", "client_email": "<redacted>", "client_id": "<redacted>", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/sepush-push-topics%40sepush-backend.iam.gserviceaccount.com", "universe_domain": "googleapis.com" }Recommendation
Adjust this code:
PyFCM/pyfcm/baseapi.py
Line 89 in c94dc6d
To be: