INNER CODE UNIT · Python
b64
MorpheApp/morphe-patches · .github/scripts/send_fcm.py:96
def b64(data: bytes) -> str:
return base64.urlsafe_b64encode(data).rstrip(b"=").decode()
header = b64(json.dumps({"alg": "RS256", "typ": "JWT"}).encode())
payload = b64(json.dumps({
"iss": sa["client_email"],
"sub": sa["client_email"],
"aud": sa.get("token_uri", "https://oauth2.googleapis.com/token"),
"iat": now,
"exp": now + 3600,
"scope": "https://www.googleapis.com/auth/firebase.messaging",
}).encode())
try:
private_key = serialization.load_pem_private_key(
sa["private_key"].encode(),
password=None,
)