public void LogOut() { session = null; connection = null; manager = null; Api.Utility.SetSecured("last.fm", "", ApiConstants.LastFmApiKey); }
public async Task <bool> LoginToLastFm() { try { var existingData = Api.Utility.GetSecured("last.fm", ApiConstants.LastFmApiKey); if (!string.IsNullOrWhiteSpace(existingData)) { session = existingData.ToObject <Session>(); if (session.Authenticated) { return(true); } if (string.IsNullOrWhiteSpace(session.APIKey) || string.IsNullOrWhiteSpace(session.APISecret)) { session.APIKey = ApiConstants.LastFmApiKey; session.APISecret = ApiConstants.LastFmSecret; } } else { session = new Session(ApiConstants.LastFmApiKey, ApiConstants.LastFmSecret); } } catch (Exception ex) { LogManager.Shared.Report(ex); session = new Session(ApiConstants.LastFmApiKey, ApiConstants.LastFmSecret); } try { return(await ShowLogin()); } catch (Exception ex) { if (ex is TaskCanceledException) { throw; } LogManager.Shared.Report(ex); } return(false); }