Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        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);
                }
            }
        }