Anda di halaman 1dari 1

// Include the Dropbox SDK. import com.dropbox.core.*; import java.io.*; import java.util.

Locale; public class Main { public static void main(String[] args) throws IOException, DbxException { // Get your app key and secret from the Dropbox developers website. final String APP_KEY = "y1s1r8ac9iyfgcm"; final String APP_SECRET = "siqiz2mjo9o3q6g"; DbxAppInfo appInfo = new DbxAppInfo(APP_KEY, APP_SECRET); DbxRequestConfig config = new DbxRequestConfig( "JavaTutorial/1.0", Locale.getDefault().toString()); DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(config, appInfo) ; String authorizeUrl = webAuth.start() // 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)"); System.out.println("3. Copy the authorization code."); String code = new BufferedReader(new InputStreamReader(System.in)).readLine().tr im(); DbxAuthFinish authFinish = webAuth.finish(code); DbxClient client = new DbxClient(config, authFinish.accessToken); System.out.println("Linked account: " + client.getAccountInfo().displayName); DbxEntry.WithChildren listing = client.getMetadataWithChildren("/"); System.out.println("Files in the root path:"); for (DbxEntry child : listing.children) { System.out.println(" " + child.name + ": " + child.toString()); }

Anda mungkin juga menyukai