private bool Login() { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); TraktSettings settings = settingsManager.Load <TraktSettings>(); TraktLogger.Info("Exchanging refresh-token for access-token"); var response = TraktAuth.GetOAuthToken(settings.TraktOAuthToken); if (response == null || string.IsNullOrEmpty(response.AccessToken)) { TraktLogger.Error("Unable to login to trakt"); return(false); } settings.TraktOAuthToken = response.RefreshToken; settingsManager.Save(settings); TraktLogger.Info("Successfully logged in"); return(true); }
internal static bool Login(string key) { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); TraktSettings settings = settingsManager.Load <TraktSettings>(); var response = TraktAuth.GetOAuthToken(key); if (response == null || string.IsNullOrEmpty(response.AccessToken)) { TraktLogger.Error("Unable to login to trakt"); return(false); } settings.IsAuthorized = true; settings.TraktOAuthToken = response.RefreshToken; settingsManager.Save(settings); TraktLogger.Info("Successfully logged in"); return(true); }
private bool Login() { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); TraktSettings settings = settingsManager.Load <TraktSettings>(); TraktLogger.Info("Exchanging {0} for access-token...", PinCode.Length == 8 ? "pin-code" : "refresh-token"); var response = TraktAuth.GetOAuthToken(PinCode.Length == 8 ? PinCode : settings.TraktOAuthToken); if (response == null || string.IsNullOrEmpty(response.AccessToken)) { TestStatus = "[Trakt.CheckPin]"; TraktLogger.Error("Unable to login to trakt, wrong pin?"); PinCode = string.Empty; return(false); } TestStatus = "[Trakt.LoggedIn]"; settings.TraktOAuthToken = response.RefreshToken; settingsManager.Save(settings); TraktLogger.Info("Successfully logged in!"); return(true); }