private async void TwitterTests_LogonAsync()
        {
            var loader = new OAuthCredentialLoader();

            Assert.IsNotNull(loader, "Unable to construct OAuthCredentialLoader");

            var credentials = loader.Load("OAuth.default.secret.json");

            Assert.IsNotNull(credentials);
            Assert.AreEqual("http://checkoutmystuff.net/", credentials.CallbackUri);

            var twitterAuth = new TwitterOAuthTokens
            {
                AccessToken       = credentials.AccessToken,
                AccessTokenSecret = credentials.AccessTokenSecret,
                CallbackUri       = credentials.CallbackUri,
                ConsumerKey       = credentials.ConsumerKey,
                ConsumerSecret    = credentials.ConsumerSecret
            };

            TwitterService.Instance.Initialize(twitterAuth);

            //TwitterService.Instance.Initialize(credentials.ConsumerKey, credentials.ConsumerSecret, credentials.CallbackUri);

            // Login to Twitter
            var loggedIn = await TwitterService.Instance.LoginAsync();

            Assert.IsTrue(loggedIn, "FAILED to login.");

            var user = await TwitterService.Instance.GetUserAsync();

            Assert.IsNotNull(user, "FAILED to get the user.");
        }
예제 #2
0
        public void OAuthCredentialLoader_Load()
        {
            var test = new OAuthCredentialLoader();

            var oathConfiguration = test.Load("OAuth.default.json");                    // File is marked as "content" - Copy if newer.

            Assert.AreEqual("asdfghjkl AccessToken asdfghjkl", oathConfiguration.AccessToken, "The AccessToken did not match.");
            Assert.AreEqual("asdfghjkl AccessTokenSecret asdfghjkl", oathConfiguration.AccessTokenSecret, "The AccessTokenSecret did not match.");
            Assert.AreEqual("http://www.SpilledMilk.com", oathConfiguration.CallbackUri, "The CallbackUri did not match.");
            Assert.AreEqual("asdfghjkl ConsumerKey asdfghjkl", oathConfiguration.ConsumerKey, "The ConsumerKey did not match.");
            Assert.AreEqual("asdfghjkl ConsumerSecret asdfghjkl", oathConfiguration.ConsumerSecret, "The ConsumerSecret did not match.");
        }
예제 #3
0
        public CredentialsViewModel()
        {
            if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                var test = new OAuthCredentialLoader();

                // TODO: File name from configuration.

                try
                {
                    _oauthCredentials = test.Load("OAuth.default.secret.json");                            // File is marked as "content" - Copy if newer.
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                BusyVisibility = ToVisibility(false);

                ConnectCommand = new RelayCommand(Connect, CanConnect);
            }
            else
            {
                // Some design-time data.

                _oauthCredentials = new OAuthCredentials
                {
                    AccessToken       = "asdfghjkl Put your cryptic token here asdfghjkl",
                    AccessTokenSecret = "asdfghjkl Put your cryptic token here asdfghjkl",
                    CallbackUri       = "http://www.SpilledMilk.com",
                    ConsumerKey       = "asdfghjkl Put your cryptic token here asdfghjkl",
                    ConsumerSecret    = "asdfghjkl Put your cryptic token here asdfghjkl"
                };

                BusyVisibility = ToVisibility(true);

                UserImage = new Uri("http://checkoutmystuff.net/Images/Check Out My Stuff Logo.png");
            }

            CallbackUrl     = _oauthCredentials?.CallbackUri;
            ConsumerKey     = _oauthCredentials?.ConsumerKey;
            ConsumerSecrect = _oauthCredentials?.ConsumerSecret;

            //if (!IsDesignModeEnabled)
            //{
            //	InitializeTwitter();
            //}
        }
예제 #4
0
        public void OAuthCredentialLoader_Construction()
        {
            var test = new OAuthCredentialLoader();

            Assert.IsNotNull(test, "Unable to construct OAuthCredentialLoader");
        }