Skip to content

Commit

Permalink
New method to retrieve access_token
Browse files Browse the repository at this point in the history
  • Loading branch information
Astrovic committed Oct 27, 2021
1 parent 95d1eb1 commit 29b1bef
Show file tree
Hide file tree
Showing 12 changed files with 1,949 additions and 86 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
v. 4.0.0
- New method to retrieve access_token
v. 3.0.0
- files/lock_file_batch
- files/search updated to v2;
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ After making your changes, to create a new version of the module you have to fol
- Uses [Titaniumifier](https://github.com/smclab/titaniumifier) to generate the zip module, with the command:

`$ titaniumifier --in . --out ./dist`

⚠️ **Titaniumifier** requires **node 8**. It does not work correctly with node version > 8.
- Import your new **ti.dropbox-commonjs-x.x.x.zip** module in the project. This will create the [**`modules/commonjs`**](https://github.com/Astrovic/TiDropboxAPIv2/tree/master/modules/commonjs) folder you had removed earlier, with the new version of the module.

All done :) Now you can send your pull request.
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var TiDropbox = require("ti.dropbox").TiDropbox;
TiDropbox.init('e9tribefg77q4wg'/*<YOUR APP KEY HERE>*/, 'https://www.dropbox.com/'/*<YOUR redirect_uri HERE>*/);
TiDropbox.init('e9tribefg77q4wg'/*<YOUR APP KEY HERE>*/, 'https://astrovicapps.com/'/*<YOUR redirect_uri HERE>*/);

var dropboxAPIv2 = require("dropboxAPIv2").dropboxAPIv2;
var selectedMethod = "";
Expand Down Expand Up @@ -57,16 +57,16 @@ for(var methodStr in dropboxAPIv2){
apiList.push(apiRow);
};
};
$.apiListTV.setData(apiList);
$.apiListTV.data = apiList;

function checkToken(){
if(Ti.App.Properties.getString('DROPBOX_TOKENS',null)){
$.loginBtn.logged = true;
$.loginBtn.setTitle("Dropbox Logout");
$.loginBtn.title = "Dropbox Logout";
$.apiListTV.show();
}else{
$.loginBtn.logged = false;
$.loginBtn.setTitle("Dropbox Login");
$.loginBtntitle = "Dropbox Login";
$.apiListTV.hide();
};
$.activityBgView.hide();
Expand Down
8 changes: 3 additions & 5 deletions app/lib/tidropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,8 @@ var TiDropbox = {};
Titanium.API.debug(e);


if (e.url.indexOf('#access_token') != -1) {
var token = e.url.split("=")[1];
token = token.substring(0, token.indexOf("&"));
if (e.url.indexOf('access_token') != -1) {
var token = e.url.match(/[?&]access_token=([^&]*)/)[1];
TiDropbox.ACCESS_TOKEN = token;
Ti.App.Properties.setString('DROPBOX_TOKENS',TiDropbox.ACCESS_TOKEN);
Ti.API.debug('tidropbox_token: ' + token);
Expand All @@ -386,7 +385,7 @@ var TiDropbox = {};
});
}
destroyAuthorizeUI();
} else if (e.url.indexOf('#error=access_denied') != -1) {
} else if (e.url.indexOf('error=access_denied') != -1) {
Ti.API.debug('tidropbox_access_denied, you need a new token');
if (TiDropbox.auth_callback != undefined) {
TiDropbox.auth_callback({
Expand All @@ -397,7 +396,6 @@ var TiDropbox = {};
}
destroyAuthorizeUI();
}

};

})();
Expand Down
Binary file added dist/ti.dropbox-commonjs-4.0.0.zip
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 2.0.0
version: 4.0.0
description: Titanium Appcelerator Javascript Dropbox API v2
author: Vittorio Sorbera, astrovicApps
license: ISC
copyright: Copyright © 2018 Vittorio Sorbera, astrovicApps
copyright: Copyright © 2021 Vittorio Sorbera, astrovicApps
name: ti.dropbox
moduleid: ti.dropbox
guid: 3e89fe63-2de2-415e-9777-a63ed2c102a1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ti.dropbox",
"version": "3.0.0",
"version": "4.0.0",
"description": "Titanium Appcelerator Javascript Dropbox API v2",
"titaniumManifest": {
"guid": "3e89fe63-2de2-415e-9777-a63ed2c102a1"
Expand All @@ -26,5 +26,8 @@
"url": "https://github.com/Astrovic/TiDropboxAPIv2/issues"
},
"homepage": "https://github.com/Astrovic/TiDropboxAPIv2#readme",
"dependencies": {
"titaniumifier": "^1.5.1"
},
"_nativeDependencies": {}
}
140 changes: 70 additions & 70 deletions ...s/commonjs/ti.dropbox/3.0.0/ti.dropbox.js → ...s/commonjs/ti.dropbox/4.0.0/ti.dropbox.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,63 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.ti || (g.ti = {})).dropbox = f()}})(function(){var define,module,exports;return (function e(t,n,r){function o(i,u){if(!n[i]){if(!t[i]){var a=typeof require=="function"&&require;if(!u&&a)return a.length===2?a(i,!0):a(i);if(s&&s.length===2)return s(i,!0);if(s)return s(i);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[i]={exports:{}};t[i][0].call(l.exports,function(e){var n=t[i][1][e];return o(n?n:e)},l,l.exports,e,t,n,r)}return n[i].exports}var i=Array.prototype.slice;Function.prototype.bind||Object.defineProperty(Function.prototype,"bind",{enumerable:!1,configurable:!0,writable:!0,value:function(e){function r(){return t.apply(this instanceof r&&e?this:e,n.concat(i.call(arguments)))}if(typeof this!="function")throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=this,n=i.call(arguments,1);return r.prototype=Object.create(t.prototype),r.prototype.contructor=r,r}});var s=typeof require=="function"&&require;for(var u=0;u<r.length;u++)o(r[u]);return o})({1:[function(require,module,exports){

module.exports = (function () { return this; })();

module.exports.location = {};

},{}],2:[function(require,module,exports){
(function (global){

module.exports.clearInterval = clearInterval;
module.exports.clearTimeout = clearTimeout;
module.exports.setInterval = setInterval;
module.exports.setTimeout = setTimeout;

// See https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowtimers-cleartimeout

function clearInterval(intervalId) {
try {
return global.clearInterval(intervalId);
}
catch (e) {
// Do nothing
return undefined;
}
}

function clearTimeout(timeoutId) {
try {
return global.clearTimeout(timeoutId);
}
catch (e) {
// Do nothing
return undefined;
}
}

function setInterval(func, delay) {
var args = [];
for (var i = 2, l = arguments.length; i < l; ++i) {
args[ i - 2 ] = arguments[ i ];
}

return global.setInterval(function () {
func.apply(this, args);
}, +delay);
}

function setTimeout(func, delay) {
var args = [];
for (var i = 2, l = arguments.length; i < l; ++i) {
args[ i - 2 ] = arguments[ i ];
}

return global.setTimeout(function () {
func.apply(this, args);
}, +delay);
}

}).call(this,require("--global--"))
},{"--global--":1}],3:[function(require,module,exports){
/**
* this code was inspired by the work done by Adam Płócieniak
* available at https://github.com/adasq/dropbox-v2-api/blob/master/dist/api.json
Expand Down Expand Up @@ -327,9 +386,11 @@ exports.dropboxAPIv2 = {
"requiresReadableStream": false,
"endpointType": "RPC",
"testParams": {
"entries": [{
"entries": [
{
"path": "/Homework/math/Prime_Numbers.txt"
}]
}
]
},
"parameters": [{
"name": "entries",
Expand All @@ -339,7 +400,7 @@ exports.dropboxAPIv2 = {
"name": "path",
"type": "String(pattern=\"(/(.|[\\r\\n])*)|(ns:[0-9]+(/.*)?)\")",
"desc": "Path in the user's Dropbox to delete."
}],
}],
}],
"returnParameters": []
},
Expand Down Expand Up @@ -3942,7 +4003,7 @@ exports.dropboxAPIv2 = {
}
}

},{}],2:[function(require,module,exports){
},{}],4:[function(require,module,exports){
(function (setTimeout){
/**
*
Expand Down Expand Up @@ -4306,9 +4367,8 @@ var TiDropbox = {};
Titanium.API.debug(e);


if (e.url.indexOf('#access_token') != -1) {
var token = e.url.split("=")[1];
token = token.substring(0, token.indexOf("&"));
if (e.url.indexOf('access_token') != -1) {
var token = e.url.match(/[?&]access_token=([^&]*)/)[1];
TiDropbox.ACCESS_TOKEN = token;
Ti.App.Properties.setString('DROPBOX_TOKENS',TiDropbox.ACCESS_TOKEN);
Ti.API.debug('tidropbox_token: ' + token);
Expand All @@ -4332,7 +4392,7 @@ var TiDropbox = {};
});
}
destroyAuthorizeUI();
} else if (e.url.indexOf('#error=access_denied') != -1) {
} else if (e.url.indexOf('error=access_denied') != -1) {
Ti.API.debug('tidropbox_access_denied, you need a new token');
if (TiDropbox.auth_callback != undefined) {
TiDropbox.auth_callback({
Expand All @@ -4343,72 +4403,12 @@ var TiDropbox = {};
}
destroyAuthorizeUI();
}

};

})();

exports.TiDropbox = TiDropbox;

}).call(this,require("--timers--").setTimeout)
},{"--timers--":4,"../lib/dropboxAPIv2":1}],3:[function(require,module,exports){

module.exports = (function () { return this; })();

module.exports.location = {};

},{}],4:[function(require,module,exports){
(function (global){

module.exports.clearInterval = clearInterval;
module.exports.clearTimeout = clearTimeout;
module.exports.setInterval = setInterval;
module.exports.setTimeout = setTimeout;

// See https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowtimers-cleartimeout

function clearInterval(intervalId) {
try {
return global.clearInterval(intervalId);
}
catch (e) {
// Do nothing
return undefined;
}
}

function clearTimeout(timeoutId) {
try {
return global.clearTimeout(timeoutId);
}
catch (e) {
// Do nothing
return undefined;
}
}

function setInterval(func, delay) {
var args = [];
for (var i = 2, l = arguments.length; i < l; ++i) {
args[ i - 2 ] = arguments[ i ];
}

return global.setInterval(function () {
func.apply(this, args);
}, +delay);
}

function setTimeout(func, delay) {
var args = [];
for (var i = 2, l = arguments.length; i < l; ++i) {
args[ i - 2 ] = arguments[ i ];
}

return global.setTimeout(function () {
func.apply(this, args);
}, +delay);
}

}).call(this,require("--global--"))
},{"--global--":3}]},{},[2])(2)
});
},{"--timers--":2,"../lib/dropboxAPIv2":3}]},{},[4])(4)
});
Loading

0 comments on commit 29b1bef

Please sign in to comment.