I’ve been developing my app with cordova on ios and it’s working without issue. Now that I’ve tried to run a build on the android platform, I’m getting the following error:
http://74029a44-9d2f-4a90-a2ba-c9e68513a3f7:3a7e7b34-cbe8-4159-9b0f-dcb8f7a7e962@localhost:5984/my_app Failed to load resource: the server responded with a status of 401 (Unauthorized)
The error is occurring during my application initialization. It looks like the app is getting the 401 when it’s trying to connect to device cblite. This is before registration and attempting to auth against sync gateway.
I don’t work on Android, but what I know about this is: The CBL HTTP listener on Android has to open an actual TCP port on the device. To prevent other apps, not trusted by you, from accessing your databases, the listener is initialized with a randomly generated username/password. This gets inserted into the database URL given to you (the two hex blobs before the @.)
No idea why this wouldn’t be working. How are you sending HTTP requests? Maybe the library you’re using is accidentally stripping out or mangling the username/password?
Hi @hideki, I’ll run a test later today and post the log of interest.
@jens, this is the only statement my app has to connect to the device db:
`
// 1st connect to couchbase that’s located
// on the device and get it’s url
cblite.getURL(function (error, url) {
if (error) {
console.log('CB Initilization error ’ + JSON.stringify(error));
reject(‘CB Initilization error’, error);
}
404 usually indicates authentication error. So userid or password could be wrong. So I would like to know why authenticate fails. Log messages from CBL Java library could help to debug.
Have you ever tried ToDo Lite PhoneGap on your device? If not, can you try it if it works?
Cookies aren’t an issue. However, if fetch ends up stripping the username/password out of the URL (or inadvertently altering them?), then it would cause these results.
(You wouldn’t have noticed on iOS, because on that platform we don’t use a password for REST-API access to CBL because we don’t open a real TCP port.)