예제 #1
0
        public async Task Can_make_protected_resource_request_with_access_token_async()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            var requestTokenResponse = await service.GetRequestTokenAsync();

            var request = requestTokenResponse.Value;

            Assert.AreEqual(requestTokenResponse.Response.StatusCode, HttpStatusCode.OK);
            Assert.NotNull(request);

            var uri = service.GetAuthorizationUri(request);

            Process.Start(uri.ToString());

            Console.WriteLine("Press the any key when you have confirmation of your code transmission.");
            var verifier = "1234567";             // <-- Debugger breakpoint and edit with the actual verifier

            var accessResult = await service.GetAccessTokenAsync(request, verifier);

            var access = accessResult.Value;

            Assert.AreEqual(accessResult.Response.StatusCode, HttpStatusCode.OK);
            Assert.IsNotNull(access);

            service.AuthenticateWith(access.Token, access.TokenSecret);
            var mentions = service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions());

            Assert.IsNotNull(mentions);
            Assert.AreEqual(20, mentions.Count());
        }
예제 #2
0
        public async Task <long> Authenticate(string requestToken, string requestVerifier)
        {
            var oauthToken = new OAuthRequestToken {
                Token = requestToken
            };
            var accessTokenResult = await service.GetAccessTokenAsync(oauthToken, requestVerifier).ConfigureAwait(false);

            accessTokenResult.Response.ThrowIfFailed();

            this.service.AuthenticateWith(accessTokenResult.Value.Token, accessTokenResult.Value.TokenSecret);
            var result = await this.service.VerifyCredentialsAsync(new VerifyCredentialsOptions()).ConfigureAwait(false);

            result.Response.ThrowIfFailed();
            this.userId = result.Value.Id;
            return(result.Value.Id);
        }
				public async Task Can_exchange_for_access_token_async()
				{
					var service = new TwitterService(_consumerKey, _consumerSecret);
					var requestTokenResponse = await service.GetRequestTokenAsync();

					Assert.AreEqual(requestTokenResponse.Response.StatusCode, HttpStatusCode.OK);
					Assert.NotNull(requestTokenResponse.Value);

					var uri = service.GetAuthorizationUri(requestTokenResponse.Value);
					Process.Start(uri.ToString());

					Console.WriteLine("Press the any key when you have confirmation of your code transmission.");
					var verifier = "1234567"; // <-- Debugger breakpoint and edit with the actual verifier

					var accessTokenResult = await service.GetAccessTokenAsync(requestTokenResponse.Value, verifier);
					var accessToken = accessTokenResult.Value;
					AssertResultWas(service, HttpStatusCode.OK);
					Assert.IsNotNull(accessToken);
				}
예제 #4
0
        public async Task Can_exchange_for_access_token_async()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            var requestTokenResponse = await service.GetRequestTokenAsync();

            Assert.AreEqual(requestTokenResponse.Response.StatusCode, HttpStatusCode.OK);
            Assert.NotNull(requestTokenResponse.Value);

            var uri = service.GetAuthorizationUri(requestTokenResponse.Value);

            Process.Start(uri.ToString());

            Console.WriteLine("Press the any key when you have confirmation of your code transmission.");
            var verifier = "1234567";             // <-- Debugger breakpoint and edit with the actual verifier

            var accessTokenResult = await service.GetAccessTokenAsync(requestTokenResponse.Value, verifier);

            var accessToken = accessTokenResult.Value;

            AssertResultWas(service, HttpStatusCode.OK);
            Assert.IsNotNull(accessToken);
        }
				public async Task Can_make_protected_resource_request_with_access_token_async()
				{
					var service = new TwitterService(_consumerKey, _consumerSecret);
					var requestTokenResponse = await service.GetRequestTokenAsync();
					var request = requestTokenResponse.Value;

					Assert.AreEqual(requestTokenResponse.Response.StatusCode, HttpStatusCode.OK);
					Assert.NotNull(request);

					var uri = service.GetAuthorizationUri(request);
					Process.Start(uri.ToString());

					Console.WriteLine("Press the any key when you have confirmation of your code transmission.");
					var verifier = "1234567"; // <-- Debugger breakpoint and edit with the actual verifier

					var accessResult = await service.GetAccessTokenAsync(request, verifier);
					var access = accessResult.Value;
					Assert.AreEqual(accessResult.Response.StatusCode, HttpStatusCode.OK);
					Assert.IsNotNull(access);

					service.AuthenticateWith(access.Token, access.TokenSecret);
					var mentions = service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions());
					Assert.IsNotNull(mentions);
					Assert.AreEqual(20, mentions.Count());
				}