bool HandleAuthResponse (JObject json)
{
var session = json.GetValue ("session");
if (session != null) {
SessionKey = session.SelectToken ("key").ToString ();
Directory.CreateDirectory (Path.GetDirectoryName (SessionKeyFile));
File.WriteAllText (SessionKeyFile, SessionKey);
Directory.CreateDirectory (Path.GetDirectoryName (LoginCacheFile));
File.WriteAllLines (LoginCacheFile, new [] { Username, Password });
} else {
SessionKey = null;
Files.Delete (SessionKeyFile);
LoggingService.LogInfo ("Could not log in to last.fm: {0}", json.GetValue ("message"));
}
return SessionKey != null;
}