Report created: 9 June 2014

Participant Information

Experience:  8 years: PHP/Node.js/Javascript/Java

Development System: MS Windows 7 x64, NetBeans. IDE 7.0.1.

 

Tasks

1. Obtain authorization credentials.

Use the following dropbox account:
        test89452@gmail.com
        dasd234
    Gmail account:
        test89452@gmail.com
        fqwf1212

Sources: download

Time spent: 5 hours

Notes:

The developer experience of obtaining of request_token and access token was good and at par with the standard OAuth based authentication process. The problem arises as I was supposed to test the APIs in Node.js environment and there was no official Node.js module available at dropbox.com. As far as third party libraries are concerned, there were more than 3. I tried my hands with them one by one but succeeded while working with the third library, named node-dbox (https://github.com/sintaxi/node-dbox). Afterwards everything moved smoothly performance wise as well as usability wise.

I just missed a comprehensive tutorial on obtaining authorization credentials from dropbox in Node JS environment. It is very much needed. The closest I found after a lot of googling was http://stackoverflow.com/questions/13211401/how-to-keep-node-dbox-token-between-page-refreshes-in-nodejs-express

I also wanted to be able to change the name off the application on user’s AppConsole https://www.dropbox.com/developers/apps/info/c4evdxg95hp12hn

 

2. Output information about the authorized user.

Sources: see sources for Task1

Time spent: 10 minutes

Notes:

This part was simple as both the API documentations https://www.dropbox.com/developers/core/docs as well as stackoverflow. I just needed to add three lines to what I had done in Task1

var client = dboxApp.client(access_token);
client.account(function(status, reply){
    res.send(reply);
});

 

3. Upload a file to the authorized Dropbox user.

Sources: download

Time spent: 25 minutes

Notes:

This task was quite simple and I managed to finish it in just 25 minutes. The below code did the trick. After user authorization, we redirect the user to upload page, where he/she selects the file to be uploaded. Once uploaded, it was easy just to rename the newly uploaded file.

 

app.post('/upload_finished', function(req, res) {
        var access_token = JSON.parse(req.session.dboxStore.access_token);
        //console.log(req.session.dboxStore.access_token);
        //console.log(req.files.file.originalFilename);
        var fileName = req.files.file.originalFilename;
        var filePath = req.files.file.path;
        console.log(req.files.file);
        
        //var request_token = JSON.parse(req.cookies.request_token);
        var client = dboxApp.client(access_token);
        fs.readFile(filePath, 'utf8', function (err,data) {
            if (err) {
                    return console.log(err);
            }
            //console.log(data.length);
            client.put(fileName, data, function(status, reply){
                fs.rename(filePath, "./files/"+fileName, function(err) {
                    if (err) throw err;
                    console.log('File uploaded!');

                        //res.redirect('/uploaded');
                    
                });
        });

 

The documentation provided at https://www.dropbox.com/developers looks enough for this task. I did not have to look elsewhere for the info.

 

4. Create a new datastore.

Sources: download

Time spent: 2 hours 20 minutes

Notes:

I tried the following code first to see if I can include the dropbox javascript library into my node application directly so as to later use the Javascript SDK APIs to retrieve data.

var vm = require('vm');
        var includeInThisContext = function(path) {
            var code = fs.readFileSync(path);
            console.log(code);
            vm.runInThisContext(code, path);
        }.bind(this);
        
        includeInThisContext(__dirname+"/jslib/dropbox-datastores-1.0.1.js");
        //require(__dirname+"/jslib/dropbox-datastores-1.0.1.js");
        
        var client = new Dropbox.Client({key: "ifjieieffiefiehf"});

This did not turn out to be successful and I got this error:

C:\node_apps\Task4>node app.js
Error: dropbox.js loaded in an unsupported JavaScript environment.
    at C:\node_apps\Task4/jslib/dropbox-datastores-1.0.1.js:2:1054
    at C:\node_apps\Task4/jslib/dropbox-datastores-1.0.1.js:6:3528
    at C:\node_apps\Task4\app.js:14:7
    at C:\node_apps\Task4\app.js:17:3
    at Object.<anonymous> (C:\node_apps\Task4\app.js:36:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

Finally I implemented the wrapper for the datastore creation API. The code was written following the documentations at https://www.dropbox.com/developers/datastore/docs/http#get_or_create_datastore for HTTP endpoints.

I tried to create a global data store first but could not do so as even after spending around 1 hour I was not able to construct a valid dsid as the formulae [dsid == '.' + dbase64(sha256(key))]
Was not very clear and there were not easily available functions for sha256 and dbase64 methods for node.js environment.

I wish there had been a good example of creating a dsid on the dropbox documentation site itself so that developers do not have to go through a lot of searching in google and stackoverflow.

 

5. Write a record into the created datastore with the JSON information {"description": "This is a test"}.

Sources: download

Time spent: 1 hour

Notes:

This task was a bit difficult as the documentation at https://www.dropbox.com/developers/datastore/docs/http#put_delta is not very clear. It is very difficult to guess that put_delta can even be used for table creation and record creation. There were no HTTP endpoint APIs for table creation and record insertion in the HTTP APIs for the datastore.

 

Questions

1. Name specifically the three biggest problems you’ve encountered and how you solved them (documentation, customer support, stackoverflow, help from a friend)?

  1. The most difficult tasks were getting any code to work in the node.js environment. There are many 3rd party NODE JS Javascript libraries which are incomplete and none of them implements the datastore APIs. I solved this problem by doing lots of google search and found many good answere at stackoverflow.
  2. The lack of a good working tutorial on getting the authorization credentials in Node.js environment. This caused me to try a number of libraries and resort to a trial and error method of accomplishing the tasks. The default Javascript library available with Dropbox does not work in Node.js environment. Solved: Documentation + Stackoverflow
  3. Handling of Encoding type of files uploaded. A good example could have been provided which detects the file encoding of the input file. This caused an issue where a PDF file being uploaded was not containing anything when it was downloaded from dropbox and opend with a PDF viewer. Did not solve it as it is not an API issue.

2. Give an approximation of how much of your time you have spent outside looking for help outside https://www.dropbox.com/developers. (0% = I've been using https://www.dropbox.com/developers only; 100% = I've used https://www.dropbox.com/developers just for registering my app)

40%

3. Have you experienced any unexpected crashes or errors? If yes, did you find the error messages useful?

No, all the errors were reasonable, and I managed to overcome them all.

4. Name at least three ways we can improve the documentation.

  1. Add more information on methods and properties in datastore APIs.
  2. Add a tutorial on getting authorization credentials in node js environment. And official module with great documentation would be an icing on the cake.
  3. A non obsfuscated version of the Javascript SDK is missing. If someone tries to write his own NODE module, they can not take inspiration from the implementation logic of the JS SDK.

5. Name at least three ways we can improve the design of the API (other than documentation).

  1. Add a possibility to get access token easier. In fact a node module can be created to accomplish this task.
  2. Creating a table and record could have had more descriptive APIs.
  3. Add a possibility to rename project names in the account.
 

www.apiusabilitytesting.com