cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Java SDK getting "Invalid authorization value in HTTP header/URL parameter"

Java SDK getting "Invalid authorization value in HTTP header/URL parameter"

UserMateUser
New member | Level 2

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

UserMateUser_0-1712171796582.png

This client is later autowired inside a service

UserMateUser_1-1712172356014.png

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

UserMateUser_2-1712172533049.png

 

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?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox 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:

View solution in original post

2 Replies 2

Greg-DB
Dropbox 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:

Здравко
Legendary | Level 20

Hi @UserMateUser,

What's that 'token' variable and where it comes from? :thinking_face: Did you try dump it just before client construction? If not, check this at the beginning.

Good luck.

Need more support?