Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FCM authTokens:generate - possible fix for you #27

Open
sdb9696 opened this issue Aug 29, 2024 · 1 comment
Open

FCM authTokens:generate - possible fix for you #27

sdb9696 opened this issue Aug 29, 2024 · 1 comment

Comments

@sdb9696
Copy link

sdb9696 commented Aug 29, 2024

Hi there,

I was able to use your library as a reference to help me migrate my firebase-messaging python library to the new FCM api. I noticed you have commented out refreshFCMInstallationToken as the requests were failing for you. I was able to get this working in my lib so thought I'd share this with you as you may want to implement it in future.

The way I got mine working was to use a modified url to include installations in front of the fid and also pass the api key in the header. Code snippet is below.

This then returns a new token with a new expiry time. I did wonder though what will happen when the existing token expires. Will it affect the registration token at all or does this just mean that a fresh installation will be required if a new registration token is needed? I'm not sure if you know the answer to this or have any thoughts...

        headers = {
            "Authorization": f"{AUTH_VERSION} {fcm_refresh_token}",
            "x-firebase-client": hb_header,
            "x-goog-api-key": self.config.api_key,
        }
        payload = {
            "installation": {
                "sdkVersion": SDK_VERSION,
                "appId": self.config.app_id,
            }
        }
        url = (
            FCM_INSTALLATION + f"projects/{self.config.project_id}/"
            "installations/{fid}/authTokens:generate"
        )
@Eneris
Copy link
Owner

Eneris commented Oct 22, 2024

Hi. Sorry for such a late reply. I've read it back in August and forgot to answer. Rest asured, I have it on my TODO list.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants