Hello Guys
I'm having some problem on initializing credentials
the example code is:
(ns upload.gcs
(:import com.google.auth.oauth2.ServiceAccountCredentials))
(def service (atom nil))
(defn credentials-from-stream [credentials-filename]
(-> credentials-filename
io/resource
io/input-stream
ServiceAccountCredentials/fromStream))
(defn initialize [project-id credentials-filename]
(let [creds (credentials-from-stream credentials-filename)
new-service (-> (StorageOptions/newBuilder)
(.setProjectId project-id)
(.setCredentials creds)
(.build)
(.getService))]
(reset! service new-service)
true))
I'm using some .json credentials to credentials filename
the error came from this part of the code:
new-service (-> (StorageOptions/newBuilder)
(.setProjectId project-id)
(.setCredentials creds)
(.build)
(.getService))
when I do
.getService it returns:
Execution error (NoSuchMethodError) at com.google.api.services.storage.Storage$Builder/setBatchPath (Storage.java:9353).
com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient$Builder.setBatchPath(Ljava/lang/String;)Lcom/google/api/client/googleapis/services/AbstractGoogleClient$Builder;I feel like I’ve spent weeks trying to get Google Cloud libraries to work in Java. Here’s how I got Firebase working. https://gist.github.com/realgenekim/2d9b14da54e71bb14ffe69afc7947bc8 I recently got Google Photos API to work, but ran into similar problem. After a week of trying to get their Java library to work, I ended up using OAuth and REST API. Was stunned at how many terrible rabbit holes I went down… everything from not being able to find the right methods [days], right classes [days]… Blind hacking eventually led to Guice version errors, and other insanities… should have put down the shovel, stepped away from the hole. Hope this helps.
for this part of the code:
(def creds (GoogleCredentials/fromStream
(io/input-stream "test1-xxxx-firebase-adminsdk-xxxx.json")))
(def o (-> (new FirebaseOptions$Builder)
(.setCredentials creds)
(.setDatabaseUrl "")
(.build))) when I use (.setCredentials creds)
gives me this same error:
Execution error (NoSuchMethodError) at com.google.api.services.storage.Storage$Builder/setBatchPath (Storage.java:9353).
com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient$Builder.setBatchPath(Ljava/lang/String;)Lcom/google/api/client/googleapis/services/AbstractGoogleClient$Builder;=<
but thanks for the snippet
anyone knows about this error?