Skip to content

Commit 30c1b0e

Browse files
authored
Merge pull request #6 from nextcloud/allow-to-use-an-app-token
Allow to login with an app token
2 parents 19403f3 + 2b14046 commit 30c1b0e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/components/nsNextcloud.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Cu.import("resource:///modules/gloda/log4moz.js");
3737
Cu.import("resource:///modules/cloudFileAccounts.js");
3838

3939
const kRestBase = "/ocs/v1.php";
40-
const kAuthPath = kRestBase + "/person/check";
40+
const kAuthPath = kRestBase + "/cloud/user";
4141
const kShareApp = kRestBase + "/apps/files_sharing/api/v1/shares";
4242
const kMaxFileSize = 1073741824;
4343
const kWebDavPath = "/remote.php/webdav";
@@ -190,7 +190,7 @@ Nextcloud.prototype = {
190190
if (!this._loggedIn) {
191191
return this._logonAndGetUserInfo(successCallback, null, true);
192192
}
193-
193+
194194
this.log.info("getting user info");
195195

196196
if (!this._userInfo) {
@@ -398,16 +398,14 @@ Nextcloud.prototype = {
398398

399399
this.log.info("Sending login information...");
400400

401-
let username = "login=" + wwwFormUrlEncode(this._userName);
402-
let password = "&password=" + wwwFormUrlEncode(this._password);
403-
let loginData = username + password;
404401
let args = "?format=json";
405402
let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
406403
.createInstance(Ci.nsIXMLHttpRequest);
407404

408-
req.open("POST", this._serverUrl + ":" + this._serverPort + kAuthPath + args, true);
405+
req.open("GET", this._serverUrl + ":" + this._serverPort + kAuthPath + args, true);
409406
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
410407
req.setRequestHeader("OCS-APIREQUEST", "true");
408+
req.setRequestHeader("Authorization", "Basic " + btoa(this._userName + ':' + this._password));
411409

412410
req.onerror = function () {
413411
this.log.info("logon failure");
@@ -447,7 +445,7 @@ Nextcloud.prototype = {
447445
}
448446
}.bind(this);
449447

450-
req.send(loginData);
448+
req.send();
451449
this.log.info("Login information sent!");
452450
},
453451

0 commit comments

Comments
 (0)