public void MockLoginCallback(FBResult result)
{
Destroy(FBComponentFactory.GetComponent<EditorFacebookAccessToken>());
if (result.Error != null)
{
BadAccessToken(result.Error);
return;
}
try
{
var json = (List<object>) MiniJSON.Json.Deserialize(result.Text);
var responses = new List<string>();
foreach (object obj in json)
{
if (!(obj is Dictionary<string, object>))
{
continue;
}
var response = (Dictionary<string, object>) obj;
if (!response.ContainsKey("body"))
{
continue;
}
responses.Add((string) response["body"]);
}
var userData = (Dictionary<string, object>) MiniJSON.Json.Deserialize(responses[0]);
var appData = (Dictionary<string, object>) MiniJSON.Json.Deserialize(responses[1]);
if (FB.AppId != (string) appData["id"])
{
BadAccessToken("Access token is not for current app id: " + FB.AppId);
return;
}
userId = (string)userData["id"];
fb.UserId = userId;
fb.AccessToken = accessToken;
isLoggedIn = true;
OnAuthResponse(new FBResult(""));
}
catch (Exception e)
{
BadAccessToken("Could not get data from access token: " + e.Message);
}
}