public void GetListRepository_ApiIsInitialized_CreatesListRepository() { Rtm.Init("test", "test"); var actual = Rtm.GetListRepository(new AuthenticationToken()); Assert.IsInstanceOf <ListRepository>(actual); }
private static async Task AuthenticateNewDesktopUser() { // Get an authentication URL for the user. This example will request authorization for READ permissions. try { var desktopAuthenticator = Rtm.GetAuthFactory().CreateDesktopAuthenticator(); var authUrl = await desktopAuthenticator.GetAuthenticationUrlAsync(PermissionLevel.Read).ConfigureAwait(false); // Instruct the user to navigate to the URL and authorize your application. They can continue using // your application after authentication in the web browser is complete. Console.WriteLine($"Step 1: Please navigate to the following URL using a web browser: {authUrl}"); Console.WriteLine("Step 2: Follow the instructions from Remember the Milk to authorize this application to access your RTM account."); Console.WriteLine("Step 3: Press [Enter] when finished"); Console.ReadLine(); var rtmUser = await desktopAuthenticator.GetAutheticatedUserAsync().ConfigureAwait(false); // Save the user data to a file or database. var userJson = rtmUser.ToJson(); File.WriteAllText("myRtmUser.json", userJson); } catch (RtmException ex) { // Read the exception details. There may be an issue with your API Key or Shared Secret, or the user may not // have followed the instructions for authentication. Console.WriteLine($"RTM Error Code: {ex.ErrorCode} -- RTM Error Message: {ex.Message}"); } }
public void FinishedAuth() { rtmAuth = rtm.AuthGetToken(frob); if (rtmAuth != null) { Preferences prefs = Application.Preferences; prefs.Set(Preferences.AuthTokenKey, rtmAuth.Token); if (rtmAuth.User != null) { prefs.Set(Preferences.UserNameKey, rtmAuth.User.Username); prefs.Set(Preferences.UserIdKey, rtmAuth.User.UserId); } } string authToken = Application.Preferences.Get(Preferences.AuthTokenKey); if (authToken != null) { Logger.Debug("Found AuthToken, checking credentials..."); try { rtm = new Rtm(apiKey, sharedSecret, authToken); rtmAuth = rtm.AuthCheckToken(authToken); timeline = rtm.TimelineCreate(); Logger.Debug("RTM Auth Token is valid!"); Logger.Debug("Setting configured status to true"); configured = true; Refresh(); } catch (Exception e) { rtm = null; rtmAuth = null; Logger.Error("Exception authenticating, reverting" + e.Message); } } }
public string GetAuthUrl() { frob = Rtm.AuthGetFrob(); string url = Rtm.AuthCalcUrl(frob, RtmNet.AuthLevel.Delete); return(url); }
private static async Task CheckAuthenticationToken() { // Load a user from JSON var userJson = File.ReadAllText("myRtmUser.json"); var user = Rtm.GetUserFactory().LoadFromJson(userJson); var tokenVerifier = Rtm.GetAuthFactory().CreateTokenVerifier(); try { if (await tokenVerifier.VerifyAsync(user.Token).ConfigureAwait(false)) { Console.WriteLine("Token is still valid."); } else { // Token is expired or otherwise invalid. you'll need to create a new authorization URL // and instruct the user to reauthorize your app. Console.WriteLine("Token is expired or invalid."); } } catch (RtmException ex) { // Some other API error was returned. Console.WriteLine($"RTM Error Code: {ex.ErrorCode}"); Console.WriteLine($"RTM Error Message: {ex.Message}"); } }
public void GetAuthFactory_ApiIsInitialized_CreatesAuthFactory() { Rtm.Init("test", "test"); var actual = Rtm.GetAuthFactory(); Assert.IsInstanceOf <AuthFactory>(actual); }
static RTM() { rtm = new Rtm(ApiKey, SharedSecret); tasks = new List <Item> (); lists = new List <Item> (); tags = new List <Item> (); locations = new List <Item> (); priorities = new List <Item> (); notes = new List <Item> (); list_lock = new object(); task_lock = new object(); location_lock = new object(); note_lock = new object(); ResetLastSync(); ResetFilter(); RTMPreferences.AccountChanged += HandleAccountChanged; RTMPreferences.FilterChanged += HandleFilterChanged; RTMPreferences.OverdueIntervalChanged += HandleOverdueIntervalChanged; RTMPreferences.OverdueNotificationChanged += HandleOverdueNotificationChanged; Services.Core.UniverseInitialized += HandleInitialized; TryConnect(); }
private static ILocationRepository InitLocationRepository() { // Load a user from JSON var userJson = File.ReadAllText("myRtmUser.json"); var user = Rtm.GetUserFactory().LoadFromJson(userJson); return(Rtm.GetLocationRepository(user.Token)); }
private static ITaskRepository GetTaskRepository() { // Load a user from JSON var userJson = File.ReadAllText("myRtmUser.json"); var user = Rtm.GetUserFactory().LoadFromJson(userJson); return Rtm.GetTaskRepository(user.Token); }
private static async Task Run() { // Initialize the API with your personal API Key and Shared Secret issued by Remember the Milk. Do this once per runtime session. var configs = LoadApiConfigs(); Rtm.Init(configs.ApiKey, configs.SharedSecret); while (true) { Console.WriteLine(); Console.WriteLine("---------------------------------------------------------"); Console.WriteLine("Main Menu - Select an option:"); Console.WriteLine(); Console.WriteLine(" 1) Authentication Examples"); Console.WriteLine(" 2) List Examples"); Console.WriteLine(" 3) Task Examples"); Console.WriteLine(" 4) Location Examples"); Console.WriteLine(); Console.WriteLine(" 0) Exit"); Console.WriteLine(); Console.WriteLine("---------------------------------------------------------"); Console.WriteLine(); Console.Write("--> "); var input = Console.ReadLine(); switch (input) { case "1": await AuthenticationExamples.Run().ConfigureAwait(false); break; case "2": await ListExamples.Run().ConfigureAwait(false); break; case "3": await TasksExamples.Run().ConfigureAwait(false); break; case "4": await LocationExamples.Run().ConfigureAwait(false); break; case "0": return; default: Console.WriteLine("Invalid Entry"); break; } } }
public void Init_ValidArgs_InitializesApi() { const string apiKey = "My API Key"; const string sharedSecret = "My Shared Secret"; Rtm.Init(apiKey, sharedSecret); Assert.AreEqual(apiKey, Rtm.ApiKey); Assert.AreEqual(sharedSecret, Rtm.SharedSecret); }
public void Initialize() { // ************************************* // AUTHENTICATION to Remember The Milk // ************************************* string authToken = Application.Preferences.Get(Preferences.AuthTokenKey); if (authToken != null) { Logger.Debug("Found AuthToken, checking credentials..."); try { rtm = new Rtm(apiKey, sharedSecret, authToken); rtmAuth = rtm.AuthCheckToken(authToken); timeline = rtm.TimelineCreate(); Logger.Debug("RTM Auth Token is valid!"); Logger.Debug("Setting configured status to true"); configured = true; } catch (RtmNet.RtmApiException e) { Application.Preferences.Set(Preferences.AuthTokenKey, null); Application.Preferences.Set(Preferences.UserIdKey, null); Application.Preferences.Set(Preferences.UserNameKey, null); rtm = null; rtmAuth = null; Logger.Error("Exception authenticating, reverting" + e.Message); } catch (RtmNet.RtmWebException e) { rtm = null; rtmAuth = null; Logger.Error("Not connected to RTM, maybe proxy: #{0}", e.Message); } catch (System.Net.WebException e) { rtm = null; rtmAuth = null; Logger.Error("Problem connecting to internet: #{0}", e.Message); } } if (rtm == null) { rtm = new Rtm(apiKey, sharedSecret); } StartThread(); }
public IEnumerable <ITaskListCore> GetAll() { yield return(allList); var lists = Rtm.ListsGetList(); foreach (var list in lists.listCollection) { ITaskListCore taskList; if (list.Smart == 1) { taskList = Factory.CreateSmartTaskList(list.ID, list.Name); } else { taskList = Factory.CreateTaskList(list.ID, list.Name); } yield return(taskList); } }
public void FinishedAuth() { rtmAuth = Rtm.AuthGetToken(frob); if (rtmAuth != null) { preferences.Set(PreferencesKeys.AuthTokenKey, rtmAuth.Token); if (rtmAuth.User != null) { preferences.Set(PreferencesKeys.UserNameKey, rtmAuth.User.Username); preferences.Set(PreferencesKeys.UserIdKey, rtmAuth.User.UserId); } } var authToken = preferences.Get(PreferencesKeys.AuthTokenKey); if (authToken != null) { Logger.Debug("Found AuthToken, checking credentials..."); try { Rtm = new RtmNet.Rtm(ApiKey, SharedSecret, authToken); rtmAuth = Rtm.AuthCheckToken(authToken); Timeline = Rtm.TimelineCreate(); Logger.Debug("RTM Auth Token is valid!"); Logger.Debug("Setting configured status to true"); IsConfigured = true; FinishInitialization(); } catch (Exception e) { Rtm = null; rtmAuth = null; Logger.Error("Exception authenticating, reverting" + e.Message); } } }
public void GetAuthFactory_ApiNotInitialized_ThrowsInvalidOperationException() { Assert.Throws <InvalidOperationException>(() => Rtm.GetAuthFactory()); }
public abstract void Execute(Rtm rtm);
public RequestManager(Rtm rtm) { mRtm = rtm; }
public void GetListRepostiory_ApiNotInitialized_ThrowsInvalidOperationException() { Assert.Throws <InvalidOperationException>(() => Rtm.GetListRepository(new AuthenticationToken())); }
public void GetListRepository_NullToken_ThrowsArgumentNullException() { Rtm.Init("test", "test"); Assert.Throws <ArgumentNullException>(() => Rtm.GetListRepository(null)); }
public void Init_NullValues_ThrowsArgumentNullException(string apiKey, string sharedSecret) { Assert.Throws <ArgumentNullException>(() => Rtm.Init(apiKey, sharedSecret)); }
public void GetUserFactory_CreatesUserFactory() { var actual = Rtm.GetUserFactory(); Assert.IsInstanceOf <UserFactory>(actual); }