matrix-org / sygnal

Sygnal: reference Push Gateway for Matrix
Apache License 2.0
164 stars 147 forks source link

Consider migrating to FCM HTTP v1 API [old API shutoff: June 2024] #313

Closed ilya-korotya closed 6 months ago

ilya-korotya commented 2 years ago

Is your feature request related to a problem? Please describe. FCM asks to stop using legacy authorization and switch to OAuth 2.0 https://firebase.google.com/docs/cloud-messaging/auth-server. But it looks like sygnal only supports authorization via Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA which is the old approach.

Describe the solution you'd like Add a field to the config that will determine what type of authorization I want to use. Legacy or OAuth 2.0.

Additional context image

reivilibre commented 2 years ago

Can you clarify: are you still able to create a legacy API key or have they shut that off completely now?

ilya-korotya commented 2 years ago

Using a legacy API key is still allowed, but not recommended. I think FCM may stop supporting legacy API key at any time.

H-Shay commented 2 years ago

The issue here is that AFAICT Sygnal currently uses the legacy HTTP API https://github.com/matrix-org/sygnal/blob/cac851bc8d750d94bb55d5e152e97c2caf2d8a9f/sygnal/gcmpushkin.py#L72, which doesn't support Oauth token authorization. We probably need to consider migrating to the HTTP v1 API although I don't see any concrete info in the docs relating to a sunset date for the legacy API.

rltas commented 1 year ago

The readme says "server key" but since the parameter is called "api_key" it still took us some time to realize that we explicitly have to enable the "Cloud Messaging API (Legacy)" and use that. If this migration isn't something that can easily be done, maybe just be a bit clearer/explicit about that.

popperwin commented 1 year ago

We probably need to consider migrating to the HTTP v1 API although I don't see any concrete info in the docs relating to a sunset date for the legacy API.

@H-Shay The legacy API will be shutdown on 20 June 2024

image
H-Shay commented 1 year ago

The legacy API will be shutdown on 20 June 2024

Thanks for the heads up!

AndrewBedscastle commented 1 year ago

I'd recommend having a look at the firebase admin SDK which is also available for python https://firebase.google.com/docs/cloud-messaging/server#firebase-admin-sdk-for-fcm We needed to migrate a lot of projects using the legacy GCM API and found admin SDK to be the most easy. I do not know it for python (we're not using python), but for Java it offers very convenient builders for messages.

Python example:

# This registration token comes from the client FCM SDKs.
registration_token = 'YOUR_REGISTRATION_TOKEN'

# See documentation on defining a message payload.
message = messaging.Message(
    data={
        'score': '850',
        'time': '2:45',
    },
    token=registration_token,
)

# Send a message to the device corresponding to the provided
# registration token.
response = messaging.send(message)
# Response is a message ID string.
print('Successfully sent message:', response)[cloud_messaging.py]

source: https://github.com/firebase/firebase-admin-python/blob/59a22b3ef3263530b1f1b61a3416ef311c24477b/snippets/messaging/cloud_messaging.py#L24-L40

PS: I am pretty sure that the deadline will be extended by Google. They won't shut every down in June 2024. One should be prepared, though.

giomfo commented 1 year ago

@wrjlewis FYI this is not possible to configure a FCM (Firebase Cloud Messaging) pusher for a new Firebase project in a Sygnal instance since June 2023.

Here is a screenshot of a new Firebase project settings in the Firebase Console:

Screenshot 2023-09-27 at 10 06 41

Only FCM HTTP v1 API is allowed for a new project.

June 2024 is the deadline for the existing projects. We should migrate asap to unblock new projects

bruno24pt commented 8 months ago

Quick check-in about the legacy API deadline in June. Heard Element-HQ moved all the stuff over, but can't see Sygnal Pushgateway. Maybe it's still in the pipeline?

Any updates or details on this? Just trying to stay in the loop.

Thanks for any info!

wrjlewis commented 8 months ago

Hey 👋

Heard Element-HQ moved all the stuff over, but can't see Sygnal Pushgateway. Maybe it's still in the pipeline?

Yep thats correct, Sygnal will be moved over shortly.

Any updates or details on this? Just trying to stay in the loop.

I can't give specifics on when exactly. But we're trying to get this scheduled asap and well ahead of the API shut off date. Lack of specifics on that just due to the team's other commitments and being a smaller team.

franzos commented 6 months ago

This is coming in like ~3 months. Is anyone working on this?

giomfo commented 6 months ago

@devonh can we consider this ticket closed by https://github.com/matrix-org/sygnal/pull/361? is there still any pending work?

wrjlewis commented 6 months ago

Support has been added in today's release - https://github.com/matrix-org/sygnal/releases/tag/v0.14.0

bmarty commented 3 months ago

FTR, this is an e-mail I have received today:

image
rltas commented 3 months ago

We’d like to let you know that due to the high number of extension requests, we have decided to delay the shutdown time to July 20, 2024.