cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

403 Forbidden error on API access through Java

403 Forbidden error on API access through Java

Amit1
New member | Level 1

I am trying to call dropbox's API's through a java based client (spring security) but I get a 403 (Forbidden) error when I do that. The error is

WARNING: POST request for "https://www.dropbox.com/1/oauth2/authorize" resulted in 403 (Forbidden); invoking error handler
Exception in thread "main" error="access_denied", error_description="Error requesting access token."

My code looks like

private String authorizeWithImplicitFlow() {
    ImplicitResourceDetails details = new ImplicitResourceDetails();
    details.setPreEstablishedRedirectUri("https://www.irctc.co.in");
    details.setAccessTokenUri("https://www.dropbox.com/1/oauth2/authorize");

    HashMap<String, String[]> parameters = new HashMap<String, String[]>();
    parameters.put("response_type", new String[] {"token"});
    parameters.put("client_id", new String[]{CLIENT_ID});
    OAuth2RestTemplate template = new OAuth2RestTemplate(details, new DefaultOAuth2ClientContext(new DefaultAccessTokenRequest(parameters)));
    OAuth2AccessToken token = template.getAccessToken();
    return token.getValue();
}

What could be reason for the 403 error? Note that I was able to successfully access the API through REST client (POSTMAN)

1 Reply 1

Steve M.
Dropbox Staff

www.dropbox.com/1/oauth2/authorize should only be accessed by a user, so I'm confused as to why your code is issuing a POST request to it at all.

I've never used Spring, so I'm not really set up to help debug this. Perhaps you can get better help on a Spring forum?

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Steve M. Dropbox Staff
What do Dropbox user levels mean?