I am working on a Spring-MVC application and I would like to integrate Dropbox functionality into it. As I read the examples, I saw that there is some code which I can use. But this involves the user copy pasting the access token, which is not applicable in real world applications, plus I cannot find a way to set the redirect URL when authentication is complete. What changes should I make so the code does not need to copy pasted, but can be retrieved directly.
Code :
public void connectToDropbox() {
DbxAppInfo appInfo = new DbxAppInfo(APP_KEY, APP_SECRET);
DbxRequestConfig config = new DbxRequestConfig("JavaTutorial/1.0",
Locale.getDefault().toString());
DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(config, appInfo);
// Have the user sign in and authorize your app.
String authorizeUrl = webAuth.start();
System.out.println("1. Go to: " + authorizeUrl);
System.out.println("2. Click \"Allow\" (you might have to log in first)");
// No, I dont want to copy the authorization code.
System.out.println("3. Copy the authorization code.");
String code = null;
try {
code = new BufferedReader(new InputStreamReader(System.in)).readLine().trim();
} catch (IOException e) {
e.printStackTrace();
}
Controller code :
@RequestMapping(value = "/logindropbox")
public String loginIntoDropbox(){
ConnectDropbox connectDropbox = new ConnectDropbox();
connectDropbox.connectToDropbox();
return "rediect:/dashboard";
}
There was only one answer I could find on SO, but that was of no use. Any help would be nice. Thanks a lot. :-)