ExFirebaseAuth icon indicating copy to clipboard operation
ExFirebaseAuth copied to clipboard

Add a method for generating custom tokens

Open Nickforall opened this issue 4 years ago • 0 comments

https://firebase.google.com/docs/auth/admin/create-custom-tokens#create_custom_tokens_using_a_third-party_jwt_library

we would need people to supply their key/client email

along the lines of:

    key = JOSE.JWK.from_pem("private key")

    JOSE.JWT.sign(key, %{"alg" => "RS256"}, %{
      iss: "firebase client email",
      sub: "firebase client email",
      aud:
        "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
      iat: :os.system_time(:seconds),
      exp: :os.system_time(:seconds) + 3600,
      uid: firebase_user_id
    })
    |> JOSE.JWS.compact()
    |> elem(1)

Nickforall avatar Nov 10 '21 14:11 Nickforall