Hi All, I am trying to just do a quick poc on connecting to box via JWTs and I have created and configured my Box App for JWT server authentication and authroized it as well in the admin console.
The trouble I am having is that when trying to establish a connection using the Box SDK for JAVA I get a null pointer exception as follows:
Exception in thread "main" java.lang.NullPointerException
at com.box.sdk.BoxDeveloperEditionAPIConnection.decryptPrivateKey(BoxDeveloperEditionAPIConnection.java:444)
...
The offending line is (arguments augmented of course): BoxDeveloperEditionAPIConnection api = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection("entId", "ClientId", "clientSecret", encryption, accessTokenCache);
Now, since this is a quick and dirty POC I am simply trying to input my private key as a string to the setPrivateKey method and I'm sure I'm doing something wrong with this approach.
Can someone tell me how I would take the box provided private key and passphrase and simply enter it as a string into the JWTEncryptionPreferences.setPrivateKey and setPrivateKeyPassword methods?
I've tried removing all the new line characters as well as removing the BEGINING PRIVATE key and END PRIVATE KEY lines as well and still getting an null pointer.
The following is the full example of what I am trying to do:
JWTEncryptionPreferences encryption = new JWTEncryptionPreferences();
encryption.setPublicKeyID("publicKey");
encryption.setPrivateKey("privateKey");
encryption.setPrivateKeyPassword("passPhrase);
encryption.setEncryptionAlgorithm(EncryptionAlgorithm.RSA_SHA_256);
IAccessTokenCache accessTokenCache = new InMemoryLRUAccessTokenCache(1);
BoxDeveloperEditionAPIConnection api = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection("entId, "clientId", "clientSecret", encryption, accessTokenCache);
System.out.println("Box api created.... {}" + api.getAccessToken());
Thanks in advance for reading/assisting!