Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replicating with a Cloudant shared database #1295

Closed
brendand opened this issue Jun 15, 2016 · 3 comments
Closed

Replicating with a Cloudant shared database #1295

brendand opened this issue Jun 15, 2016 · 3 comments

Comments

@brendand
Copy link
Contributor

brendand commented Jun 15, 2016

In Cloudant you can grant another Cloudant user access to one of your databases. When you do this, the user being shared with sees the database under the shared tab in the Cloudant dashboard with the database name in the following format:

username/databasename

Where username is the user who is sharing the database and databasename is the database being shared.

When I setup my replicator, I pass in a URL of the format:

https://myusername.cloudant.com/username%2Fdatabasename

However, when I start trying to replicate, I get the following error:

13:48:20.681‖ Sync: CBLSocketChangeTracker[0x6000001aefc0 db-068f2e250ba7420b8b2a6fa1d2da6dd3]: GET //myusername.cloudant.com/username%2Fdb-068f2e250ba7420b8b2a6fa1d2da6dd3/_changes?feed=normal&heartbeat=300000&style=all_docs
13:48:20.752‖ Sync: CBLRestPusher[https://myusername.cloudant.com/username%2Fdb-068f2e250ba7420b8b2a6fa1d2da6dd3]: Server is CouchDB/1.0.2 (Erlang OTP/17)
13:48:20.752‖ CBLRemoteJSONRequest[POST https://myusername.cloudant.com/username%2Fdb-068f2e250ba7420b8b2a6fa1d2da6dd3/_revs_diff]:
 Got error CBLHTTP[404, "Database does not exist.", <https://myusername.cloudant.com/username%2Fdb-068f2e250ba7420b8b2a6fa1d2da6dd3/_revs_diff>]

I've confirmed I have full read/write access to the shared database in Cloudant.

It appears that the name of the database is username/databasename, but I can't be too sure of that. It may be required that to replicate with a shared database that a different kind of parameter needs to be sent to indicate that the database is not one of the databases in your main account, but is a shared database.


  • Version: 1.3 beta commit e5f6434
  • Client OS: OS X 10.11
  • Server: Cloudant CouchDB
@snej
Copy link
Contributor

snej commented Jun 16, 2016

The URL in the HTTP request looks correct: https://myusername.cloudant.com/username%2Fdb-068f2e250ba7420b8b2a6fa1d2da6dd3/_revs_diff.

The URL of the database in the dashboard may not correspond to the actual REST URL. Click on the "API" button at the top of the dashboard and it'll show you the actual URL.

@brendand
Copy link
Contributor Author

brendand commented Jun 16, 2016

Oh interesting. I didn't think to click on that.

It seems that the URL is like this:

https://username.cloudant.com/db-068f2e250ba7420b8b2a6fa1d2da6dd3/_all_docs

Where username is the other user's name. Ok, so then maybe it'll work if I simply provide their username instead of mine there.

I'll give that a try. However, normally I specify the username and password for my account with basic auth:

NSURL *requestURL = [self.serverURL URLByAppendingPathComponent:self.databaseDocument.documentID];

self.pullReplicator = [self.databaseDocument.couchDatabase createPullReplication: requestURL];
self.pullReplicator.authenticator = [CBLAuthenticator basicAuthenticatorWithName:self.username password:self.password];

self.pushReplicator = [self.databaseDocument.couchDatabase createPushReplication: requestURL];
self.pushReplicator.authenticator = [CBLAuthenticator basicAuthenticatorWithName:self.username password:self.password];

But I don't have their username or password, so I'm not entirely sure how this would work. Maybe I use their URL but my username and password?

I'll see what happens.

@brendand
Copy link
Contributor Author

Well what do you know? It worked! I'll close this issue now then.

Thanks for the tip Jens!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants