We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Amit1
11 years agoNew member | Level 1
403 Forbidden error on API access through Java
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
Replies have been turned off for this discussion
- Steve M.11 years ago
Dropbox Staff
www.dropbox.com/1/oauth2/authorizeshould 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?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!