public void ToFile(string filename=null)
{
if (filename == null)
{
filename = dataPath;
}
if (filename == null)
{
filename = Constants.DATA_DIR + @"\credentials.json";
}
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(filename, json);
}
}
/// <summary> /// Log out of the companion API and remove local credentials /// </summary> public void Logout() { // Remove everything other than the local email address Credentials = CompanionAppCredentials.FromFile(); Credentials.machineToken = null; Credentials.machineId = null; Credentials.appId = null; Credentials.password = null; Credentials.ToFile(); CurrentState = State.NEEDS_LOGIN; }