olucurious / olucurious/PyFCM

Breaking changes in pyfcm 2.1.0 where explicit project_id is set

Open Beginner friendly
#380 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
814
Forks
209
PR merge metrics
No merged PRs in 30d

Description

Summary

This commit adjusted the way the project_id is used when FCMNotification is instantiated:
https://github.com/olucurious/PyFCM/commit/80fec94ce99a70277a33f7983b1f0fdf796ccdee

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:
https://github.com/olucurious/PyFCM/blob/c94dc6d64e7e33c30b4442a172fb24f2e02f8dd1/pyfcm/baseapi.py#L89

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:
https://github.com/olucurious/PyFCM/blob/c94dc6d64e7e33c30b4442a172fb24f2e02f8dd1/pyfcm/baseapi.py#L89

To be:

project_id = self._project_id or getattr(self.credentials, "project_id", None)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pyfcm/baseapi.py at the referenced line in the project_id handling, then compare it with the linked commit and the FCMNotification instantiation shown in the issue. Done means an explicitly supplied project_id is still used when service-account credentials contain a different project_id.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, python
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.