1
votes

I want to know if it is possible to access (at least read-access) to a private Dropbox folder without oauth.

The case is, I have a Heroku app that needs to access files and folders in a given private Dropbox folder.

Looking at the docs, the only way is through oAuth (https://www.dropbox.com/developers/core/start/android). However, my Heroku app needs to access the files and folders of a given Dropbox folder, is the App key and App secret enough to do this?

What is the right approach?

    @Test
        public void test() throws IOException, DbxException {
            FileOutputStream outputStream = new FileOutputStream("test.txt");
            DbxRequestConfig config = new DbxRequestConfig("mydbapp/1.0", Locale.getDefault().toString());
            DbxClient client = new DbxClient(config, Constants.accessToken);
            System.out.println("Linked account: " + client.getAccountInfo().displayName);
            DbxEntry.File md = null;
            try {
                List<DbxEntry.File> revs = client.getRevisions("/test.txt");
                md = client.getFile("/test.txt", null,  outputStream);
            } catch (DbxException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                outputStream.close();
            }
            assertNotNull(md);
}

I've been trying to debug this code, but it keeps throwing "not found" error, even if the file is in the account dropbox folder. What could be missing in this code?

1
The only way to access the Dropbox API is to use OAuth. It looks like your code is doing this fine, assuming Constants.accessToken is a valid access token for the account you're trying to access. If the client.getAccountInfo() call succeeds, then the OAuth part of your code is correct. Can you provide the actually error message and stack trace you get? I would assume you just don't have a file at the path /test.txt. Try calling metadata on "/" to see what's there. - user94559
@smarx thanks for your reply, actually with the generated token, without any user intervention my code can access drobox files, (see my answer below) - quarks

1 Answers

0
votes

Without client-side authentication (or at least I mean user intervention) it was possible to access dropbox files/data using the "Generated Token"

The problem with this code, is not actually the code, but with the way the Dropbox app was created. The files were stored in the root dropbox path, however the code is looking for the file in the /Apps/{appName}/ folder path.