Does anybody have a experience connecting elixir with Firebase?

Hello community,

My goal is to send a message from elixir back end server to an android application. I came to the conclusion that google’s firebase is currently the best option.
My problem is related to authorization and sending a message to the console Firebase.
Having downloaded my secret json from I tried to link elixir with the platform. The problem here is that I struggle dealing with that jwt token - (FunctionClauseError) no function clause matching in :jose_jwk.from/1

defmodule App.Firebase do
  @moduledoc """
  Module for sending messages through Firebase Cloud Messaging.

  @fcm_url ""
  @service_account_path "priv/firebase/serviceAccountKey.json"

  alias JOSE.{JWK, JWS, JWT}

  def send_message(token, message) do
    service_account = Jason.decode!(!(@service_account_path))
    jwt = generate_jwt(service_account)

    IO.puts("JWT generated successfully.")

    headers = [
      {"Authorization", "Bearer #{jwt}"},
      {"Content-Type", "application/json"}

    body = %{
      message: %{
        token: token,
        notification: %{
          title: "Notification Title",
          body: message
    |> Jason.encode!()

    IO.puts("Sending message to FCM...")

    case, body, headers) do
      {:ok, %HTTPoison.Response{status_code: 200, body: response_body}} ->
        IO.puts("Message sent successfully!")

      {:ok, %HTTPoison.Response{status_code: status_code, body: response_body}} ->
        IO.puts("Failed to send message. Status code: #{status_code}")
        IO.inspect(re my problem is withsponse_body)

      {:error, %HTTPoison.Error{reason: reason}} ->
        IO.puts("Error occurred while sending message")

  defp generate_jwt(service_account) do
    iat = :os.system_time(:second)
    exp = iat + 3600 # 1 hour expiration

    claims = %{
      "iss" => service_account["client_email"],
      "sub" => service_account["client_email"],
      "aud" => "",
      "iat" => iat,
      "exp" => exp,
      "scope" => ""

    private_key = service_account["private_key"]
    jwk = JWK.from_pem(private_key)
    {_, jwt} = claims |> JWT.sign(jwk) |> JWS.compact


Have someone encountered with this before? Is this the right way anyway or I am at a dead end

I’m also trying to connect to Firebase, but I’m trying to use Pigeon V2, which uses Goth for authentication. In addition to using the latest Pigeon I also picked up PR 235 to get some Goth related improvements. My authentication seems to be going fine, my problem is getting my sender_id to match. But you might find that Goth is a useful way to get your token working, if your struggles with JOSE don’t get you anywhere.

And if you get to having a SENDER_ID_MISMATCH and figure out a meaningful way to debug it, please share!