I’ve been playing around with the _facebook REST calls. Consider the following:
curl http://my.server.ip.address:4984/{dbname}/_facebook -H "Content-Type: application/json" -vX POST -d @body.json
And body.json is the following:
{
"access_token": "CAAULMWm0eXYBAFDo4ZBSIWEl0sha5Vx4srQy6HA88ym4NOx56oyG3fE7ehi6jlo71U4msh1ejwcRToScUziBSwkN2JDlfl8dsZAPVzexnZB5I03cH81NTsxgAXKmKzX9q9sgb8bZBaUDxzfMl5b2mqFNJzg8Tdg84nJBMqDXBzKzXCRDoMGVzToOE8hgp62GoY0E94BPOPx2H0UJwNYZBbAvVv6mJPZBAZD",
"email": "notmyaddress@something.com",
"remote_url": "http://totallynotmysite.com"
}
What I have learned, is that as long as the access_token string is valid, this will work. “email” and “remote_url” don’t seem to do anything. In fact, you can leave them out entirely.
Even with a bogus “email”, if the access_token is valid, a _sync:user:60503124651 document is created (the number is the user’s facebook id) and in the document it includes the accurate email address (pulled from facebook). Also a document named _sync:useremail:myactualaddress@correct.com is created with a single object {“username”: “60503124651”}.
When I logout of the app that generated the token, then this POST to /{dbname}/_facebook fails. (which it should, because the token is now dead)
Here are my questions:
- Can any valid access token from any application (e.g. from an app that isn’t mine) successfully login to POST /{dbname}/_facebook?
- If so, how do I allow users who have subscribed (paid for) my app in… and keep users who have not subscribed out?
- Maybe if there was a way to register my Facebook appID(s) in couchbase so that it would only create users for access_tokens that have a corresponding appID embedded in it. Like, put an appID field in the sync_gateway_config file…?
- What was the intention behind including “email” and “remote_url” in the json POST? It was supposed to do something, no?
- What does the “passwordhash_bcrypt” field refer to? (found in the _sync:user:60503124651 document) I can’t imagine that’s my facebook password, but since I never provided a password to the API, what is it?
Kind regards,
David