I’m hoping you can help point me in the right direction. I keep getting unauthorized errors during replication.
My sync config looks like:
{
"facebook" : { "register": true },
"interface": "0.0.0.0:4984",
"adminInterface": "0.0.0.0:4985",
"log": [
"Shadow",
"CRUD+",
"REST+",
"Changes+",
"Attach+"
],
"databases": {
"sync_gateway": {
"server": "http://myserver:8091",
"bucket": "sync_gateway"
}
}
}
In my app, the Facebook login ui pops up, I put in my credentials and get back an access_token:
var auth = AuthenticatorFactory.CreateFacebookAuthenticator (access_token);
In db/_user I’m able to see the newly created user.
In my app, I subscribe to the change event handler for push and pull replication.
pull.Changed += ReplicationProgress;
push.Changed += ReplicationProgress;
Which gets caught as unauthorized here:
private void ReplicationProgress(object replication, ReplicationChangeEventArgs args)
{
if (args.Source.LastError != null)
{
var httpError = args.Source.LastError as HttpResponseException;
if (httpError != null && httpError.StatusCode == System.Net.HttpStatusCode.Unauthorized)
{
LoginValid = false;
And shows up in the log as:
2015-07-21T16:38:05.493Z HTTP: #340: GET /sync_gateway/
2015-07-21T16:38:05.493Z HTTP: #340: --> 401 Login required (2.3 ms)
2015-07-21T16:38:05.682Z HTTP: #341: GET /sync_gateway/
2015-07-21T16:38:05.682Z HTTP: #341: --> 401 Login required (1.7 ms)
2015-07-21T16:38:05.857Z HTTP: #342: GET /sync_gateway/_session
2015-07-21T16:38:06.068Z HTTP: #343: GET /sync_gateway/_session
2015-07-21T16:38:06.253Z HTTP: #344: POST /sync_gateway/_facebook
2015-07-21T16:38:06.449Z HTTP: #345: POST /sync_gateway/_facebook
2015-07-21T16:38:06.899Z HTTP: #346: GET /sync_gateway/_local/b675658c09c4a0649334bb432c26809
acae4f92e
2015-07-21T16:38:06.900Z HTTP: #346: --> 401 Login required (2.2 ms)
2015-07-21T16:38:07.065Z HTTP: #347: GET /sync_gateway/_local/64cb8db244e37ab0461be80437f3685
b37cb4cdb
2015-07-21T16:38:07.066Z HTTP: #347: --> 401 Login required (2.2 ms)
Am I missing a step somewhere? From what I’ve read, I think all I need to do is call CreateFacebookAuthenticator( access_token) and the rest should be handled by Couchbase Lite/Sync Gateway.
I also put request to the new user with a known good admin_channels.
Thanks for your help.