Skip to main content
Question

Genarate Authorization Code

  • May 22, 2025
  • 3 replies
  • 28 views

Forum|alt.badge.img

I've created two Apps in developer console. One with JWT authentication type and the second one with Auth 2 type. In both cases I cannot generate the Authorization Code in order to call the Get Token API. I want to integrate with Java. Could you please suggest a solution?

3 replies

Forum|alt.badge.img

Have you taken a look at the readme for the Java SDK? 

https://github.com/box/box-java-sdk

Alex, Box Developer Advocate


Forum|alt.badge.img

Hi Alex, thank you for the response. My requirement is create folder and upload file into Box using SDK or APIs. Actually I created folders and uploaded files into Box using both SDK and APIs. But I used developer token for that which we cannot be used in production.

When I used the statement BoxDeveloperEditionAPIConnection api = BoxDeveloperEditionAPIConnection.getUserConnection("18958745833", boxConfig, accessTokenCache); in Java to get the connection I'm getting following error:

Exception in thread "main" java.lang.NullPointerException
    at com.box.sdk.BoxDeveloperEditionAPIConnection.decryptPrivateKey(BoxDeveloperEditionAPIConnection.java:659)
    at com.box.sdk.BoxDeveloperEditionAPIConnection.constructJWTAssertion(BoxDeveloperEditionAPIConnection.java:602)
    at com.box.sdk.BoxDeveloperEditionAPIConnection.authenticate(BoxDeveloperEditionAPIConnection.java:431)
    at com.box.sdk.BoxDeveloperEditionAPIConnection.tryRestoreUsingAccessTokenCache(BoxDeveloperEditionAPIConnection.java:571)
    at com.box.sdk.BoxDeveloperEditionAPIConnection.getUserConnection(BoxDeveloperEditionAPIConnection.java:333)
    at com.box.sdk.BoxDeveloperEditionAPIConnection.getAppUserConnection(BoxDeveloperEditionAPIConnection.java:310)
    at com.box.sdk.BoxDeveloperEditionAPIConnection.getUserConnection(BoxDeveloperEditionAPIConnection.java:396)
    at com.teknowmics.smartdocs.mavenproject2.AccessAsAppUser.main(AccessAsAppUser.java:48)

 

The config json I used is :

{
  "boxAppSettings": {
    "clientID": "06yxbqs7u75yce3ewxvk60pjy30xatfp",
    "clientSecret": "********************************",
    "appAuth": {
      "publicKeyID": "",
      "privateKey": "",
      "passphrase": ""
    }
  },
  "enterpriseID": "886081033"
}

 

Could you please suggest me what is wrong within my implementation, or an alternative solution?


Forum|alt.badge.img

Hi Alex its working fine now. I think the issue was on the config json the public and private key pair was not available. Thank you for your support. I expect your further assistance if I face any new issue.