Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed helper.js in test cases #59

Open
wants to merge 7 commits into from

1 participant

@jstroem

Updated the helper.js so it now works properly.
This was related to issue #58 the only real update it does is if you dont create your own access_token.json it creates one for you.

It also updates the timer in the testcase so the user has time to copy the link. This is only usefull if you dont run the testcases from npm but uses mocha directly.

It also updated the README so the root param for dbox.app is now documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 20, 2012
  1. @jstroem

    Updated readdir

    jstroem authored
Commits on Jan 14, 2013
  1. @jstroem

    pulled latest

    jstroem authored
Commits on Jan 15, 2013
  1. @jstroem
  2. @jstroem
  3. @jstroem

    doc'ed root param

    jstroem authored
  4. @jstroem

    removed the conflicts

    jstroem authored
  5. @jstroem

    removed the conflicts2

    jstroem authored
This page is out of date. Refresh to see the latest.
View
4 README.md
@@ -69,7 +69,9 @@ Creating a functional `dbox` client is a four step process.
### Step 1
var dbox = require("dbox")
- var app = dbox.app({ "app_key": "umdez34678ck01fx", "app_secret": "tjm89017sci88o6" })
+ var app = dbox.app({ "app_key": "umdez34678ck01fx", "app_secret": "tjm89017sci88o6"[, "root": "sandbox"] })
+
+_NB_: the root parameter is to change between the two different dropbox app types there are. `sandbox` means 'App folder' and `dropbox` means 'Full Dropbox', default is `sandbox`.
### Step 2
View
1  dbox.js
@@ -489,4 +489,3 @@ exports.app = function(config){
}
}
-
View
1  test/all.js
@@ -9,6 +9,7 @@ describe("all", function(){
var client, ref;
before(function(done){
+ this.timeout(20000); //To give the testrunner time for accepting the dropbox access
helpers.auth(app, function(access_token){
client = app.client(access_token)
done()
View
3  test/config/app.json.sample
@@ -1,4 +1,5 @@
{
"app_key": "",
- "app_secret": ""
+ "app_secret": "",
+ "root": "sandbox"
}
View
44 test/config/helpers.js
@@ -2,24 +2,32 @@ var fs = require("fs")
var prompt = require("prompt")
exports.auth = function(app, callback){
- var token = JSON.parse(fs.readFileSync(__dirname + "/access_token.json"))
- var client = app.client(token)
- client.account(function(status, account){
- if(status == 200){
- callback(token)
- }else{
- app.requesttoken(function(status, request_token){
- prompt.start()
- prompt.get(['please authorize application at the following url and enter when done\n' + request_token.authorize_url], function (err, result) {
- if (err) { return 1 }
- app.accesstoken(request_token, function(status, access_token){
- fs.writeFile(__dirname + "/access_token.json", JSON.stringify(access_token), function(err){
- if (err) throw err;
- callback(access_token)
- })
+ var makeNewAccessToken = function() {
+ app.requesttoken(function(status, request_token){
+ prompt.start()
+ prompt.get(['please authorize application at the following url and enter when done\n' + request_token.authorize_url], function (err, result) {
+ if (err) { return 1 }
+ app.accesstoken(request_token, function(status, access_token){
+ fs.writeFile(__dirname + "/access_token.json", JSON.stringify(access_token), function(err){
+ if (err) throw err;
+ callback(access_token)
})
})
- })
- }
- })
+ })
+ })
+ }
+
+ if (fs.existsSync(__dirname + "/access_token.json")) {
+ var access_token = JSON.parse(fs.readFileSync(__dirname + "/access_token.json"))
+ var client = app.client(access_token)
+ client.account(function(status, account){
+ if(status == 200){
+ callback(access_token)
+ }else{
+ makeNewAccessToken();
+ }
+ })
+ } else {
+ makeNewAccessToken();
+ }
}
Something went wrong with that request. Please try again.