google-cloud

2019-06-28T14:41:39.000400Z

Hello Guys

2019-06-28T14:41:51.000800Z

I'm having some problem on initializing credentials

2019-06-28T14:45:08.003300Z

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))

2019-06-28T14:45:29.003800Z

I'm using some .json credentials to credentials filename

2019-06-28T14:45:42.004100Z

the error came from this part of the code:

new-service (-> (StorageOptions/newBuilder)
                                  (.setProjectId project-id)
                                  (.setCredentials creds)
                                  (.build)
                                  (.getService))

2019-06-28T14:46:48.005100Z

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;

genekim 2019-07-06T07:21:38.006500Z

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.

2019-07-09T20:20:33.006800Z

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)))

2019-07-09T20:20:59.007100Z

when I use (.setCredentials creds)

2019-07-09T20:21:16.007300Z

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;

2019-07-09T20:21:17.007500Z

=<

2019-07-09T20:21:23.007700Z

but thanks for the snippet

2019-06-28T14:47:00.005600Z

anyone knows about this error?