Welcome! Please see the About page for a little more info on how this works.

0 votes
in Java Interop by

I am hoping to be able to make use of the Quickbooks libraries from Intuit. They have a Java SDK.


My goal is to be able to use their Oauth2 library to enable my clojure app to query the quickbooks API,


Up until this point I've been using OAuth v1 but this is being deprecated so I need to have a replacement OAuth2 flow set up very soon. It made sense to me to use their officially supported library.

I've added these lines to my project.clj file

[com.intuit.quickbooks-online/ipp-v3-java-devkit-pom "6.0.2" :extension "pom"] [com.intuit.quickbooks-online/ipp-v3-java-data "6.0.2" :extension "pom"]
[com.intuit.quickbooks-online/ipp-v3-java-devkit "6.0.2" :extension "pom"] [com.intuit.quickbooks-online/oauth2-platform-api "6.0.2" :extension "pom"]

I run lein deps and the libraries are successfully downloaded from maven.

I then fire up a repl. However. all the above lines seem to do is give me access to the com.intuit.ipp.data. namespace, and not to com.intuit.oauth2. . What would I need to do to to use the oauth2 parts of the SDK? I look in their sample apps and the oauth2 libraries look like they should be available to me but they are not.

My experience and understanding of the finer points of Java interop are laughably minimal, so please use short words when describing what I might have done wrong or need to do better. Thanks.

1 Answer

+1 vote
selected by
Best answer

Works for me
user=> (import '[com.intuit.oauth2.client OAuth2PlatformClient]) com.intuit.oauth2.client.OAuth2PlatformClient user=> ^D bfabry@18723-bfabry ~/C/c/quickbooks> cat deps.edn 12:14:35 {:deps {com.intuit.quickbooks-online/oauth2-platform-api {:mvn/version "6.0.2"}}}

Could you share a little more about your setup and what you're trying?

Thank you for having a look at this, it's greatly appreciated.

I'm trying to use the OAuth2 library but even though it is clearly being downloaded and I can see it in lein deps :tree, I can't seem to use it.

I tried making a brand new project with "lein new qb", then added the line

[com.intuit.quickbooks-online/oauth2-platform-api "6.0.2" :extension "pom"]

into project.clj.

I run "lein deps :tree" and can see this in the output

$ lein deps :tree
 [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
 [com.intuit.quickbooks-online/oauth2-platform-api "6.0.2" :extension "pom"]
   [com.fasterxml.jackson.core/jackson-databind "2.9.9"]
     [com.fasterxml.jackson.core/jackson-annotations "2.9.0"]
     [com.fasterxml.jackson.core/jackson-core "2.9.9"]
   [commons-codec "1.13"]
   [commons-lang "2.6"]
   [javax.annotation/javax.annotation-api "1.3.2"]
   [oauth.signpost/signpost-commonshttp4 "1.2"]
   [oauth.signpost/signpost-core ""]
   [org.apache.ant/ant "1.10.6"]
     [com.sun/tools "1.8.0" :scope "system"]
     [org.apache.ant/ant-launcher "1.10.6"]
   [org.apache.httpcomponents/httpclient "4.5.3"]
     [commons-logging "1.2"]
   [org.apache.httpcomponents/httpcore "4.4.6"]
   [org.json/json "20160810"]
   [org.slf4j/slf4j-api "1.7.25"]
 [nrepl "0.6.0" :exclusions [[org.clojure/clojure]]]
 [org.clojure/clojure "1.10.0"]
   [org.clojure/core.specs.alpha "0.2.44"]
   [org.clojure/spec.alpha "0.2.176"]

so I am sure the library has been found and downloaded.

I then fired up a REPL and tried typing the command you showed in the answer above and I get a ClassNotFoundException...

qb.core=> (import '[com.intuit.oauth2.client OAuth2PlatformClient])
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).

I'm on OSX and this is my java -version, if this might be relevant.

openjdk version "1.8.0_212"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b03)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b03, mixed mode)
I'm not actually sure what ':extension "pom"' does in lein. Try removing it?
That was something I copied directly from instructions about how to install artefacts from Maven.  Not understanding Maven at all, I assumed that this was just something that was required.  Turns out that it's not.  And it works without it.  Thank you for this, I clearly needed a bit of guidance to try the easy stuff first.  I'm still mildly confused as to why it appears correctly in the deps tree (which is why i assumed the dependencies line was correct), but the fact that it works now is all I currently care about.  Thanks again.