Пример #1
0
        static void Main(string[] args)
        {
            Uri requestTokenEndPoint = new Uri(REQUEST_TOKEN_END_POINT);
            Uri authorizeEndPoint    = new Uri(AUTHORIZE_END_POINT);
            Uri accessTokenEndPoint  = new Uri(ACCESS_TOKEN_END_POINT);

            ClientCredentials credentials = new ClientCredentials(CLIENT_IDENTIFIER, CLIENT_SHARED_SECRET);

            try
            {
                NegotiationTokenRequest negotiationTokenRequest = NegotiationTokenRequest.Create(requestTokenEndPoint, credentials);
                NegotiationToken        negotiationToken        = negotiationTokenRequest.GetToken();

                Console.WriteLine("Negotiation Token: " + negotiationToken.Value);
                Console.WriteLine("Negotiation Token Secret: " + negotiationToken.Secret);

                Uri authorizationUri = AuthorizationUri.Create(authorizeEndPoint, negotiationToken);

                Console.WriteLine(authorizationUri);
                Console.ReadLine(); // Wait for user authorization.

                AccessTokenRequest accessTokenRequest = AccessTokenRequest.Create(accessTokenEndPoint, credentials, negotiationToken);
                AccessToken        accessToken        = accessTokenRequest.GetToken();

                Console.WriteLine("Access Token: " + accessToken.Value);
                Console.WriteLine("Access Token Secret: " + accessToken.Secret);
            }
            catch (WebException ex)
            {
                Console.WriteLine(new StreamReader(ex.Response.GetResponseStream()).ReadToEnd());
                Environment.Exit(0);
            }
        }
Пример #2
0
        public void RetrieveRequestToken()
        {
            Uri uri = new Uri("http://term.ie/oauth/example/request_token.php");
            NegotiationTokenRequest request = NegotiationTokenRequest.Create(uri, credentials);

            NegotiationToken token = request.GetToken();

            Assert.That(token.Value, Is.Not.Empty);
            Assert.That(token.Secret, Is.Not.Empty);
        }
Пример #3
0
        public void RetrieveRequestToken()
        {
            Uri uri = new Uri(REQUEST_TOKEN_END_POINT);
            NegotiationTokenRequest request = NegotiationTokenRequest.Create(uri, credentials);

            NegotiationToken token = request.GetToken();

            Assert.That(token.Value, Is.Not.Empty);
            Assert.That(token.Secret, Is.Not.Empty);
        }