Missing user password with REST Api parsing on facebook user connection
I am trying to implement a Facebook login under a Symfony2 project using the parse.com REST Api.
Here is the code I am using to call CURL:
$headers = array(
"Content-Type: application/json",
"Content-Length: " . strlen($facebookJson),
"X-Parse-Application-Id: " . $applicationId,
"X-Parse-REST-API-Key: " . $parseRestAPIKey
);
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $facebookJson);
$data = curl_exec($handle);
curl_close($handle);
The variable $facebookJson
represents authData:
{
"facebook": {
"id": "user Facebook id number as a string",
"access_token": "an authorized Facebook access token for the user",
"expiration_date": "token expiration date of the format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
}
}
In this example, the user is not a logged in user in the parsing, so he must create a new user (as stated in the documentation ), but instead of creating a new user, the following error message appears:
"{" code ": 201," error ":" missing user password "}
Since I'm using Facebook to register a user, I don't think it should ask for a password, the documentation doesn't mention it.
Any suggestions to fix this issue?
Should I try another approach to inject Facebook login using parsing? (maybe it is easier, for example with parse javascript sdk).
source to share
You missed the authData field. Here's an example JSON from the Parse documentation:
{
"authData": {
"twitter": {
"id": "12345678",
"screen_name": "ParseIt",
"consumer_key": "SaMpLeId3X7eLjjLgWEw",
"consumer_secret": "SaMpLew55QbMR0vTdtOACfPXa5UdO2THX1JrxZ9s3c",
"auth_token": "12345678-SaMpLeTuo3m2avZxh5cjJmIrAfx4ZYyamdofM7IjU",
"auth_token_secret": "SaMpLeEb13SpRzQ4DAIzutEkCE2LBIm2ZQDsP3WUU"
}
}
}
source to share