Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SDK with free account and "enterpriseID": "0" leads to The API returned an error code [400] invalid_grant #1218

Closed
gaurav-bagga opened this issue Dec 16, 2023 · 3 comments
Assignees
Labels
question Added to questions

Comments

@gaurav-bagga
Copy link

  • [ x] I have checked that the SDK documentation doesn't solve my issue.
  • [ x] I have checked that the API documentation doesn't solve my issue.
  • [x ] I have searched the Box Developer Forums and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
  • [ x] I have searched Issues in this repo and my issue isn't already reported.

Description of the Issue

I am trying very basic example of authenticating with generated config.json using JWT mechanism. I am able to connect using developer token however JWT is failing. I have tried both Java and NodeJS sdk both result in same error.

I found this link which claims in free account you cannot use JWT. The post thread is from 2023 however just wanted to know my assumption regarding free account is correct or not from the previous link.

I am attaching maven project that I am trying out.

com.box.test.zip

Steps to Reproduce

Try running attached maven project.

Expected Behavior

Should authenticate.

Error Message, Including Stack Trace

Exception in thread "main" com.box.sdk.BoxAPIResponseException: The API returned an error code [400] invalid_grant - Please check the 'sub' claim. The 'sub' specified is invalid.
	at com.box.sdk.BoxAPIResponse.toBoxResponse(BoxAPIResponse.java:147)
	at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:616)
	at com.box.sdk.BoxAPIRequest.sendWithoutRetry(BoxAPIRequest.java:325)
	at com.box.sdk.BoxDeveloperEditionAPIConnection.authenticate(BoxDeveloperEditionAPIConnection.java:334)
	at com.box.sdk.BoxDeveloperEditionAPIConnection.refresh(BoxDeveloperEditionAPIConnection.java:452)
	at com.box.sdk.BoxAPIConnection.lockAccessToken(BoxAPIConnection.java:1126)
	at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:584)
	at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:380)
	at com.box.sdk.BoxJSONRequest.send(BoxJSONRequest.java:106)
	at com.box.sdk.BoxJSONRequest.send(BoxJSONRequest.java:17)
	at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:347)
	at com.box.sdk.BoxJSONRequest.send(BoxJSONRequest.java:101)
	at com.box.sdk.BoxUser.getCurrentUser(BoxUser.java:199)
	at com.box.test.Main.main(Main.java:55)

Versions Used

Java SDK: 4.6.1
Java: 11

@mhagmajer
Copy link
Contributor

Yes, I confirm that it does look like you're unable to use JWT with a free account (enterpriseId 0). You could mitigate this by using a different authentication method or working with a sandbox for a real enterprise id.

I'll close this ticket now. Feel free to reopen if you have additional questions.

@gaurav-bagga
Copy link
Author

@mhagmajer thanks for the response, I'll get a subscription to work with JWT.

@gaurav-bagga
Copy link
Author

@@mhagmajer Need little insight you mentioned in previous comment "working with a sandbox for a real enterprise id." do you mean I will need "Business Plan and higher", I went for "Personal" and I see same result.

I'll really appreciate if you could please confirm my assumption above.

Just as a side note, Oauth2 and Developer Tokens work in free account at least for basic API cannot say for all features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Added to questions
Projects
None yet
Development

No branches or pull requests

7 participants