We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.
Forum Discussion
UserMateUser
8 months agoNew member | Level 2
Java SDK getting "Invalid authorization value in HTTP header/URL parameter"
Hello!
I'm using Java SDK and trying to add dropbox into my app. I was following the guide from dropbox github https://github.com/dropbox/dropbox-sdk-java/tree/main
When I try to check if it works, I get exception from the subject at the line with
FullAccount account = dropboxClient.users().getCurrentAccount();
(dropboxClient is an instance of DbxClientV2)
I initialize dropbox client as a bean on startup using access token generated from api dev console, token seems to be passed correctly as I debuged it during initialization
This client is later autowired inside a service
But when it comes to the client call in the debugger I see that access token is empty, while config seems to be correctly passed
Am I initializing it wrong? Maybe there should be other parameters, or I need to additionaly authorize my app before trying to use any methods?
Oh and also, as I understood, if the app to be deployed somewhere, there should be used another way of authorization for other users?
It looks like you're using this constructor, where you provide the DbxRequestConfig and an access token String. That is fine and should work. To confirm, I tried this condensed version of your code, with the latest v6.1.0 of the Dropbox Java SDK:
DbxRequestConfig config = DbxRequestConfig.newBuilder("TMS/1.0").build(); String token = "<REDACTED>"; DbxClientV2 dropboxClient = new DbxClientV2(config, token); FullAccount account = dropboxClient.users().getCurrentAccount(); System.out.println(account.getName().getDisplayName());
That worked successfully for me. You may want to also try this basic version to see if this works for you to try to narrow down where this is breaking in your setup.
And I see you mentioned checking that 'token' was set properly for you originally, but I recommend stepping through the rest of your process to see if/where something may be getting changed. We can't provide support for Beans or autowiring though, as that's not made by Dropbox.
For reference, there are a number of ways of using the Dropbox app authorization functionality, and exactly how you set it up will depend on your scenario and requirements. I recommend referring to the following resources for more information:
- https://developers.dropbox.com/oauth-guide
- https://www.dropbox.com/developers/documentation/http/documentation#authorization
- https://dropbox.tech/developers/using-oauth-2-0-with-offline-access
- https://github.com/dropbox/dropbox-sdk-java/tree/main/examples/examples/src/main/java/com/dropbox/core/examples/authorize
- Greg-DBDropbox Staff
It looks like you're using this constructor, where you provide the DbxRequestConfig and an access token String. That is fine and should work. To confirm, I tried this condensed version of your code, with the latest v6.1.0 of the Dropbox Java SDK:
DbxRequestConfig config = DbxRequestConfig.newBuilder("TMS/1.0").build(); String token = "<REDACTED>"; DbxClientV2 dropboxClient = new DbxClientV2(config, token); FullAccount account = dropboxClient.users().getCurrentAccount(); System.out.println(account.getName().getDisplayName());
That worked successfully for me. You may want to also try this basic version to see if this works for you to try to narrow down where this is breaking in your setup.
And I see you mentioned checking that 'token' was set properly for you originally, but I recommend stepping through the rest of your process to see if/where something may be getting changed. We can't provide support for Beans or autowiring though, as that's not made by Dropbox.
For reference, there are a number of ways of using the Dropbox app authorization functionality, and exactly how you set it up will depend on your scenario and requirements. I recommend referring to the following resources for more information:
- https://developers.dropbox.com/oauth-guide
- https://www.dropbox.com/developers/documentation/http/documentation#authorization
- https://dropbox.tech/developers/using-oauth-2-0-with-offline-access
- https://github.com/dropbox/dropbox-sdk-java/tree/main/examples/examples/src/main/java/com/dropbox/core/examples/authorize
- ЗдравкоLegendary | Level 20
Hi UserMateUser,
What's that 'token' variable and where it comes from? 🤔 Did you try dump it just before client construction? If not, check this at the beginning.
Good luck.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,875 PostsLatest Activity: 4 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!