Skip to main content

Firebase token generation

Project description

FireBased

A based implementation of the Firebase API. This project is a partial wrapper around the Firebase API.

With just the teeniest bit of extra work, you can hook this up like someone did in Push-Server to a REST API and have a full-fledged push notification server.

Privacy Notice

Note that App developers CANNOT see the device you used to register with. Therefore, the device you register the FCM token with does not need to match the device you actually use the token with. However, once you have associated an FCM token with a given device, at this point, the app developer CAN save that association.

Note From The Creator

If you are using this, you are a developer. You know what you are doing. I am not responsible for any misuse of this software. I am not responsible for any bans or other actions taken against accounts using this software.

If you are hiring, e-mail isaacikogan@gmail.com. Let's chat :)! If not, say hi anwyways!

Helpful Tips

There are only a few identifiers you need to make requests. All of them can be found in the APK of the app you want to register firebase for:

  • google_api_key e.g. "AIzaSyA1b2C3dE4f5G6H7I8J9K0LmNOpQrStUvWx"
  • google_app_id e.g. "1:123456789012:android:abcdefghijklm1234567"
  • google_app_package e.g. "com.example.app"
  • google_app_name e.g. "api-project-123456789012"
  • google_android_cert e.g. "12345678A1B2C3D4E5F6G7H8I9J0KLMNOPQRSTU"

For your convenience, here is a basic example script that can generate a GCM token:

import asyncio

from FireBased.client.client import FireBasedClient
from FireBased.client.proto import CheckInRequestMessage, CheckInResponseMessage
from FireBased.client.schemas import RegisterInstallRequestBody, RegisterInstallRequestBodyJsonBody, RegisterGcmRequestBody, FirebaseInstallationRequestResponse, RegisterGcmRequestResponse
from FireBased.ext.synthetic_data import create_synthetic_check_in, create_mobile_user_agent

google_api_key = "AIzaSyA1b2C3dE4f5G6H7I8J9K0LmNOpQrStUvWx"  # Firebase API key
google_app_id = "1:123456789012:android:abcdefghijklm1234567"  # Firebase app ID
google_app_package = "com.example.app"  # Package name of the Android app
google_app_name = "api-project-123456789012"  # Firebase app name
google_android_cert = "12345678A1B2C3D4E5F6G7H8I9J0KLMNOPQRSTU"  # Sha-1 APK signing cert


async def generate_gcm_token() -> str:
    # Starts an HTTP client under the hood. Best to use in an async context manager for safety.
    async with FireBasedClient() as fb:
        # Create a synthetic check-in payload.
        # Note that according to ChatGPT, developers can't access the data you send here.
        # All they can really check is the Firebase ID, GCM token, and the Android ID.
        check_in_payload: CheckInRequestMessage = create_synthetic_check_in()
        check_in_response: CheckInResponseMessage = await fb.check_in(body=check_in_payload)

        # Create the installation registration payload
        register_install_payload: RegisterInstallRequestBody = RegisterInstallRequestBody(
            app_public_key=google_api_key,
            app_package=google_app_package,
            app_name=google_app_name,
            json_body=RegisterInstallRequestBodyJsonBody(appId=google_app_id),
            user_agent=create_mobile_user_agent(),
            app_cert=google_android_cert
        )

        # Register the installation
        install_data: FirebaseInstallationRequestResponse = await fb.register_install(
            body=register_install_payload
        )

        # Finally, register the GCM token using the data from the previous requests
        gcm_response: RegisterGcmRequestResponse = await fb.register_gcm(
            body=RegisterGcmRequestBody.from_models(
                install_request_body=register_install_payload,
                install_request_response=install_data,
                check_in_request_response=check_in_response
            )
        )

        return gcm_response.token


if __name__ == '__main__':
    gcm_token: str = asyncio.run(generate_gcm_token())
    print(f"Generated GCM token: {gcm_token}")

Latest pertinent data is found at https://github.com/firebase/firebase-js-sdk

Contributors

  • Isaac Kogan - Creator, Primary Maintainer, and Reverse-Engineering - isaackogan
  • Lastrise - Reverse-Engineering - lastrise

See also the full list of contributors who have participated in this project.

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

firebased-0.0.3.post1.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

firebased-0.0.3.post1-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file firebased-0.0.3.post1.tar.gz.

File metadata

  • Download URL: firebased-0.0.3.post1.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for firebased-0.0.3.post1.tar.gz
Algorithm Hash digest
SHA256 65d1dd2bd4d4d956dfa05cf182b83839e00ac3d8fe13f2784dfa0c31b613ffac
MD5 c3fefacb1c048fe66e2efb0354af06ab
BLAKE2b-256 ba39f3d0854cb0964390fe21d4e5ef679df16315f76bbfea92f69d722b1570f9

See more details on using hashes here.

File details

Details for the file firebased-0.0.3.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for firebased-0.0.3.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 97b9726e778e19ecab9ab9382898d05108aa593f2eb4daf3d4b895e883a521c8
MD5 87d94a511be9e108c5dd9eff2b16a106
BLAKE2b-256 74c18916b34132023f1a0173a2e1e708f1d9293f94ba360a55f0ff54340f9628

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page