triniwiz/nativescript-couchbase-plugin

Need Basic Authentication

Closed this issue · 5 comments

Hi, I don't see ways how to connect this to the Sync Gateway with Basic Authentication.
It would be great to have method push.setBasicAuthenticator("user", "password"); like here https://github.com/nabil-mansouri/nativescript-couchbaselite
Or at least ability to provide auth cookie.

There is the follow just not documented (need all the help I can get) 😃 so please test it and LMK

createPullReplication(remoteUrl: string, username?: string, password?: string): Replicator;
createPushReplication(remoteUrl: string, username?: string, password?: string): Replicator;

Thank you, this works without calling setContinuos(true). Otherwise I see error:

this.push = this.database.createPushReplication(`${gateway}${this.dbName}`, login, password);
this.pull = this.database.createPullReplication(`${gateway}${this.dbName}`, login, password);
this.push.setContinuous(true); // works once if comment this line
this.pull.setContinuous(true); // works once if comment this line
this.push.start();
this.pull.start();

*** JavaScript call stack:
(
0 setContinuous@[native code]
1 setContinuous@file:///app/tns_modules/nativescript-couchbase-plugin/couchbase-plugin.js:444:31
2 startSync@file:///app/couchbase.service.js:19:32
3 @file:///app/connect/connect.component.js:34:31
4 onInvoke@file:///app/tns_modules/@angular/core/bundles/core.umd.js:3890:43
5 run@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:138:49
6 @file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:883:37
7 onInvokeTask@file:///app/tns_modules/@angular/core/bundles/core.umd.js:3881:47
8 runTask@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:188:57
9 drainMicroTaskQueue@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:595:42
10 @file:///app/tns_modules/nativescript-angular/platform-common.js:143:44
11 notify@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:110:31
12 @[native code]
13 notifyAppStarted@file:<\M-b\M^@\M-&>
)
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This configuration object is readonly.'

Thanks for testing

I released a new version I remove the old way of setting the user after you create rep you now have

pull.setUserNameAndPassword("user","password");
pull.setSessionId("SomeId");
pull.setSessionIdAndCookieName("SomeId","SomeCookieName");

Thank you!