Exemple #1
0
        /// <summary>
        /// Complete the authorization, check the frob, retrieve and store the token as preference.
        /// </summary>
        /// <param name="frob">
        /// A <see cref="System.String"/> indicating the frab value.
        /// </param>
        /// <returns>
        /// A <see cref="Auth"/>
        /// </returns>
        public static Auth AuthComplete(string frob)
        {
            Auth auth;

            try {
                auth = rtm.AuthGetToken(frob);
            } catch (RtmException e) {
                Log <RTM> .Error(AddinManager.CurrentLocalizer.GetString("Failed to complete authentication."), e.Message);

                return(null);
            }
            rtm.AuthToken = auth.Token;
            timeline      = rtm.TimelineCreate();
            return(auth);
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
        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();
        }