Skip to content

Breaking changes in pyfcm 2.1.0 where explicit project_id is set #380

Description

@c4talyst

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions