title: "error" : "invalid_token: Could not parse auth token." When generating JWT for Firebase in Clojure
body: <p>Trying to write write a wrapper around the Firebase REST API (see <a href="https://github.com/cloudfuji/taika" rel="nofollow">https://github.com/cloudfuji/taika</a> for the full source), and the auth token seems to be failing. The functions are simple wrappers around the Firebase-provided Java library options (<a href="https://github.com/firebase/firebase-token-generator-java" rel="nofollow">https://github.com/firebase/firebase-token-generator-java</a>)</p>
  
  <p>The code is simple:</p>
  
  <pre><code>(ns taika.auth
    (:require [clojure.string :as string]
              [clj-http.client :as client]
              [cheshire.core :as json])
    (:import [com.firebase.firebase-token-generator.security.token]
             [org.json.JSONOBject]))
  
  (defn token-generator [secret-key]
    (com.firebase.security.token.TokenGenerator. secret-key))
  
  (defn create-token [token-generator auth-data &amp; [admin?]]
    (let [token-options (doto (com.firebase.security.token.TokenOptions.)
                          (.setAdmin (or admin? false)))]
      (.createToken token-generator (org.json.JSONObject. auth-data) token-options)))
  </code></pre>
  
  <p>Generating the token, the looks reasonable (example secret-key, of course):</p>
  
  <pre><code>(let [tg (token-generator "abc123")
                    auth-data {:email "example@example.com" :api_key "my-api-key"}
                    admin? false]
                (create-token tg auth-data admin?))
  
   =&gt; "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2IjowLCJpYXQiOjEzNjIxNjEzMDJ9.8701406fad76b2dff83bf38a18d91a95ed7787f255e7dd534a77e7daa0c58c59"
  </code></pre>
  
  <p>But when using the token in REST API requests, it fails with: </p>
  
  <pre><code>{ "error" : "invalid_token: Could not parse auth token." }
  </code></pre>
  
  <p>The ruby library doesn't seem to have the same problem.</p>
  
  <p>Again, the full source source is at <a href="https://github.com/cloudfuji/taika/blob/master/src/taika/auth.clj" rel="nofollow">https://github.com/cloudfuji/taika/blob/master/src/taika/auth.clj</a> </p>