Sync gateway facebook login behaviour

Hi. I’m having a weird issue (to me, anyhow!) issue with facebook login.

When I hit sync gateway with a _facebook POST, it gives me a 400 Bad Request, with the error message “Cannot register new user: email is missing”. The email field is present in the JSON payload though. In the curl below, the email matches the Facebook account used to generate the (munged in this post) access token.

Any help is greatly appreciated!

curl http://localhost:4984/distillednotes-gws/_facebook -H "Content-Type: application/json" -vX POST -d     {"access_token":"CAAJkAfvUlgQBAH1lHICgY6T8YWSHi7sIa5O7Dx4wXVM7qLZBqaVaGoM6r6Eyngyl7H8DmotwDsEdVKQaUqhP66845aoegrYGzm5Lst9CY2ZBuyuxcPQJ8XtKGY7gL2IbQCRHq1ZBAnrkXl6h92OyaqhACZAJndMMvYqSkDDY5k17Y3RS","email":"rodfrey@gmail.com"}
   Trying ::1...
* Connected to localhost (::1) port 4984 (#0)
> POST /distillednotes-gws/_facebook HTTP/1.1
> Host: localhost:4984
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 262
>
* upload completely sent off: 262 out of 262 bytes
< HTTP/1.1 400 Bad Request
< Content-Type: application/json
< Server: Couchbase Sync Gateway/1.1.1
< Date: Fri, 06 Nov 2015 15:32:43 GMT
< Content-Length: 77
<
* Connection #0 to host localhost left intact
{"error":"Bad Request","reason":"Cannot register new user: email is missing"}

Hi @rodfrey,

Can you check that the facebook access token used has the permissions to access the user’s email? On the back end, Sync Gateway will fetch the user id and email from Facebook. It may not be needed in the payload of the request to Sync Gateway though.

James