I’ve setup my gateway to use Facebook login but it seems to be authenticating fine but un the subsequent request i get a 401 Login required. I seem to be experiencing the same issue described here Trouble authenticating to Sync Gateway with Facebook but I’m using different environment.
Sync Gateway: 1.0.4
OS: iOS 8.4
22:10:42.653018 HTTP: #1064: GET /mydb/_session
22:10:42.749865 HTTP: #1065: POST /mydb/_facebook
22:10:42.954709 HTTP: #1066: GET /mydb/_local/02159cbbed8c3c0b560949425e87e598d753cb24
22:10:42.954778 HTTP: #1066: --> 401 Login required (0.2 ms)
Response from /mydb/_facbeook
"authentication_handlers": ["default", "cookie"],
Seems like the session is not saved in the client?
Are you using the iOS or .NET SDK?
Make sure to add the email permission when integrating facebook login in your app.
Would it be possible to update to the 1.1 release of SG and Couchbase Lite?
I’m using the iOS sdk. I’m not keen to upgrade sync gateway just yet because it’s being used on a production site and I’d have to do some testing before I make a switch. Is this a known issue that would be fixed by an upgrade? (it seems like a client side issue in that the authentication works, and it creates a new account if there wasn’t one already with the email address from Facebook so that’s not the issue)
Ok I understand .
I haven’t found any issue related to Facebook auth with 1.0.4.
Does it return 401 every time after the GET
/mydb/_local/:checkpoint request or is it occasional?
The cookie is normally returned by the POST
/mydb/_facebook in the
Set-Cookie header and will be used subsequently in the replication.
Can you get hold of it and check if it’s valid with this endpoint?
I returns 401 everytime after
One thing based on your mention of the headers; I did check the headers (via Charles Proxy) and I do notice something that could cause problems but maybe you would know better. I run the gateway behind a reverse proxy so the end point is really accessed
/sync/mydb/_facebook but the path that is set in the Set-Cookie header is /mydb
SyncGatewaySession=71024df0844bfd76929f122613f4e519974fde59; Path=/mydb/; Expires=Thu, 06 Aug 2015 22:10:42 UTC
Ah yes that may be the reason.
Can you try to use the session cookie returned to initialize a new replication with the
setCookie method as outlined here with
/ for the path?
Well I guess I will do the authentication the same way I’m doing google, using my own server side authentication and setting the cookie manually. Must say the iOS lib seems to fall a bit short (I thought it was supposed to be more mature than the android version)