We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
Zahra1
6 months agoExplorer | Level 3
oauth flow with spring boot
hello ,
I'm trying to integrate Dropbox with my Spring Boot application and enable the OAuth flow so users can use their Dropbox accounts within my application. However, it isn't working, and I'm s...
Здравко
Legendary | Level 20
Hi Zahra1,
Did you try the workflow here? 🧐 If not, give it a try.
If something is still confusing you, share some more details. 😉
Good luck.
Zahra1
6 months agoExplorer | Level 3
i've tried this :
import com.dropbox.core.DbxRequestConfig;
import com.dropbox.core.v2.DbxClientV2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@Service
public class DropboxService {
@Value("${dropbox.app.key}")
private String appKey;
@Value("${dropbox.app.secret}")
private String appSecret;
public DbxClientV2 getClient(String accessToken) {
DbxRequestConfig config = new DbxRequestConfig("APPFEATURE");
return new DbxClientV2(config, accessToken);
}
}
@Controller
public class DropboxController {
@Value("${dropbox.appKey}")
private String DROPBOX_APP_KEY;
@Value("${dropbox.appSecret}")
private String DROPBOX_APP_SECRET;
@Value("${dropbox.redirect.uri}")
private String DROPBOX_REDIRECT_URI;
private DbxWebAuth webAuth;
@GetMapping("/dropbox/auth")
public RedirectView authenticate() {
DbxRequestConfig config = DbxRequestConfig.newBuilder("dropbox/spring-boot-app").build();
DbxAppInfo appInfo = new DbxAppInfo(DROPBOX_APP_KEY, DROPBOX_APP_SECRET);
webAuth = new DbxWebAuth(config, appInfo);
DbxWebAuth.Request webAuthRequest = DbxWebAuth.newRequestBuilder()
.withRedirectUri(DROPBOX_REDIRECT_URI, new DbxStandardHttpRequestor.Config() ) //DbxStandardHttpRequestor.Config()
.build();
String authorizeUrl = webAuth.authorize(webAuthRequest);
return new RedirectView(authorizeUrl);
}
@GetMapping("/dropbox/callback")
public String callback(@RequestParam String code) {
try {
DbxAuthFinish authFinish = webAuth.finishFromCode(code);
String accessToken = authFinish.getAccessToken();
// Use the access token to create a DbxClientV2 instance
DbxRequestConfig config = DbxRequestConfig.newBuilder("dropbox/spring-boot-app").build();
DbxClientV2 client = new DbxClientV2(config, accessToken);
// Get the current account info as an example
FullAccount account = client.users().getCurrentAccount();
System.out.println("Account name: " + account.getName().getDisplayName());
return "redirect:/success";
} catch (DbxException ex) {
ex.printStackTrace();
return "redirect:/error";
}
}
}
Cannot resolve symbol 'DbxStandardHttpRequestor'
<dependency>
<groupId>com.dropbox.core</groupId>
<artifactId>dropbox-core-sdk</artifactId>
<version>5.4.0</version>
</dependency>
- Здравко6 months agoLegendary | Level 20
Zahra1 wrote:i've tried this :
...
DbxWebAuth.Request webAuthRequest = DbxWebAuth.newRequestBuilder()
.withRedirectUri(DROPBOX_REDIRECT_URI, new DbxStandardHttpRequestor.Config() ) //DbxStandardHttpRequestor.Config()
.build();
...Cannot resolve symbol 'DbxStandardHttpRequestor'
Hm... Why do you think that such a class should be there at all? Where you saw documentation about such an usage? 🤔
Just take a look on some of the examples and follow the idea there. 😉
By the way... you are using short lived token only! Keep in mind that for long term access you would need refresh token too if you need long term access.
- Greg-DB6 months agoDropbox Staff
Zahra1 Здравко is correct; the Dropbox Java SDK does not define a 'DbxStandardHttpRequestor' class. Perhaps you meant 'StandardHttpRequestor'? The withRedirectUri method takes a String and DbxSessionStore anyway though, not an HttpRequestor.
In any case, check out the examples folder for examples of using the Java SDK functionality.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 6 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!