Пример #1
0
        public void FinishedAuth()
        {
            rtmAuth = rtm.AuthGetToken (frob);
            if (rtmAuth != null) {
                var prefs = Application.Instance.Preferences;
                prefs.Set (Tasque.Preferences.AuthTokenKey, rtmAuth.Token);
                if (rtmAuth.User != null) {
                    prefs.Set (Tasque.Preferences.UserNameKey, rtmAuth.User.Username);
                    prefs.Set (Tasque.Preferences.UserIdKey, rtmAuth.User.UserId);
                }
            }

            var authToken = Application.Instance.Preferences.Get (Tasque.Preferences.AuthTokenKey);
            if (authToken != null) {
                Debug.WriteLine ("Found AuthToken, checking credentials...");
                try {
                    rtm = new Rtm (ApiKey, SharedSecret, authToken);
                    rtmAuth = rtm.AuthCheckToken (authToken);
                    timeline = rtm.TimelineCreate ();
                    Debug.WriteLine ("RTM Auth Token is valid!");
                    Debug.WriteLine ("Setting configured status to true");
                    Configured = true;
                    Refresh ();
                } catch (Exception e) {
                    rtm = null;
                    rtmAuth = null;
                    Trace.TraceError ("Exception authenticating, reverting" + e.Message);
                }
            }
        }
Пример #2
0
        public override void Initialize()
        {
            // *************************************
            // AUTHENTICATION to Remember The Milk
            // *************************************
            var authToken = Application.Instance.Preferences.Get (Tasque.Preferences.AuthTokenKey);
            if (authToken != null) {
                Debug.WriteLine ("Found AuthToken, checking credentials...");
                try {
                    rtm = new Rtm (ApiKey, SharedSecret, authToken);
                    rtmAuth = rtm.AuthCheckToken (authToken);
                    timeline = rtm.TimelineCreate ();
                    Debug.WriteLine ("RTM Auth Token is valid!");
                    Debug.WriteLine ("Setting configured status to true");
                    Configured = true;
                } catch (RtmApiException e) {
                    Application.Instance.Preferences.Set (Tasque.Preferences.AuthTokenKey, null);
                    Application.Instance.Preferences.Set (Tasque.Preferences.UserIdKey, null);
                    Application.Instance.Preferences.Set (Tasque.Preferences.UserNameKey, null);
                    rtm = null;
                    rtmAuth = null;
                    Trace.TraceError ("Exception authenticating, reverting" + e.Message);
                } catch (RtmWebException e) {
                    rtm = null;
                    rtmAuth = null;
                    Trace.TraceError ("Not connected to RTM, maybe proxy: #{0}", e.Message);
                } catch (WebException e) {
                    rtm = null;
                    rtmAuth = null;
                    Trace.TraceError ("Problem connecting to internet: #{0}", e.Message);
                }
            }

            if (rtm == null)
                rtm = new Rtm (ApiKey, SharedSecret);

            StartThread ();
        }
Пример #3
0
        /// <summary>
        /// After the user has authenticated your application on the Rtm web site call this 
        /// method with the FROB (either stored from <see cref="AuthGetFrob"/> or returned in the URL
        /// from the Rtm web site) to get the users token.
        /// </summary>
        /// <param name="frob">The string containing the FROB.</param>
        /// <returns>A <see cref="Auth"/> object containing user and token details.</returns>
        public Auth AuthGetToken(string frob)
        {
            if( sharedSecret == null ) throw new SignatureRequiredException();

            Hashtable parameters = new Hashtable();
            parameters.Add("method", "rtm.auth.getToken");
            parameters.Add("frob", frob);

            RtmNet.Response response = GetResponse(parameters);
            if( response.Status == ResponseStatus.OK )
            {
                Auth auth = new Auth(response.AllElements[0]);
                return auth;
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Пример #4
0
        /// <summary>
        /// Gets the full token details for a given mini token, entered by the user following a 
        /// web based authentication.
        /// </summary>
        /// <param name="miniToken">The mini token.</param>
        /// <returns>An instance <see cref="Auth"/> class, detailing the user and their full token.</returns>
        public Auth AuthGetFullToken(string miniToken)
        {
            Hashtable parameters = new Hashtable();
            parameters.Add("method", "rtm.auth.getFullToken");
            parameters.Add("mini_token", miniToken.Replace("-", ""));
            RtmNet.Response response = GetResponse(parameters);

            if( response.Status == ResponseStatus.OK )
            {
                Auth auth = new Auth(response.AllElements[0]);
                return auth;
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Пример #5
0
        /// <summary>
        /// Checks a authentication token with the Rtm service to make
        /// sure it is still valid.
        /// </summary>
        /// <param name="token">The authentication token to check.</param>
        /// <returns>The <see cref="Auth"/> object detailing the user for the token.</returns>
        public Auth AuthCheckToken(string token)
        {
            Hashtable parameters = new Hashtable();
            parameters.Add("method", "rtm.auth.checkToken");
            parameters.Add("auth_token", token);

            RtmNet.Response response = GetResponse(parameters);
            if( response.Status == ResponseStatus.OK )
            {
                Auth auth = new Auth(response.AllElements[0]);
                return auth;
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Пример #6
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();
        }
Пример #7
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);
                }
            }
        }