google-cloud

Google Cloud Platform: Clojure + {GAE, GCE, anything else on Google Platform}
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;

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?