/// <summary>
        /// Gets the request token and secret.
        /// </summary>
        /// <returns></returns>
        public string GetRequestToken()
        {
            var uri = new Uri(Global._APP_REQUESTTOEKN_URL);

            // Generate a signature
            oAuthToken oAuth     = new oAuthToken();
            string     nonce     = oAuth.GenerateNonce();
            string     timeStamp = oAuth.GenerateTimeStamp();
            string     parameters;
            string     normalizedUrl;
            string     signature = oAuth.GenerateSignature(uri, _consumerKey, _consumerSecret,
                                                           String.Empty, String.Empty, "GET", timeStamp, nonce, oAuthBase2.SignatureTypes.HMACSHA1,
                                                           out normalizedUrl, out parameters);

            // Encode the signature
            signature = HttpUtility.UrlEncode(signature);

            // Now buld the url by appending the consumer key, secret timestamp and all.
            StringBuilder requestUri = new StringBuilder(uri.ToString());

            requestUri.AppendFormat("?oauth_consumer_key={0}&", _consumerKey);
            requestUri.AppendFormat("oauth_nonce={0}&", nonce);
            requestUri.AppendFormat("oauth_timestamp={0}&", timeStamp);
            requestUri.AppendFormat("oauth_signature_method={0}&", "HMAC-SHA1");
            requestUri.AppendFormat("oauth_version={0}&", "1.0");
            requestUri.AppendFormat("oauth_signature={0}", signature);

            // createa request to call the dropbox api.
            string request = WebRequest(Method.GET, (new Uri(requestUri.ToString())).AbsoluteUri, string.Empty);
            //request.Method = WebRequestMethods.Http.Get;

            //// Get the response.
            //WebResponse response = request.GetResponse();

            // Read the response
            string queryString = request;

            var parts = queryString.Split('&');

            this.Token       = parts[1].Substring(parts[1].IndexOf('=') + 1);
            this.TokenSecret = parts[0].Substring(parts[0].IndexOf('=') + 1);
            return(request);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the request token and secret.
        /// </summary>
        /// <returns></returns>
        public string GetRequestToken()
        {
            var uri = new Uri(Global._APP_REQUESTTOEKN_URL);

            // Generate a signature
            oAuthToken oAuth = new oAuthToken();
            string nonce = oAuth.GenerateNonce();
            string timeStamp = oAuth.GenerateTimeStamp();
            string parameters;
            string normalizedUrl;
            string signature = oAuth.GenerateSignature(uri, _consumerKey, _consumerSecret,
                String.Empty, String.Empty, "GET", timeStamp, nonce, oAuthBase2.SignatureTypes.HMACSHA1,
                out normalizedUrl, out parameters);

            // Encode the signature
            signature = HttpUtility.UrlEncode(signature);

            // Now buld the url by appending the consumer key, secret timestamp and all.
            StringBuilder requestUri = new StringBuilder(uri.ToString());
            requestUri.AppendFormat("?oauth_consumer_key={0}&", _consumerKey);
            requestUri.AppendFormat("oauth_nonce={0}&", nonce);
            requestUri.AppendFormat("oauth_timestamp={0}&", timeStamp);
            requestUri.AppendFormat("oauth_signature_method={0}&", "HMAC-SHA1");
            requestUri.AppendFormat("oauth_version={0}&", "1.0");
            requestUri.AppendFormat("oauth_signature={0}", signature);

            // createa request to call the dropbox api.
            string request = WebRequest(Method.GET, (new Uri(requestUri.ToString())).AbsoluteUri, string.Empty);
            //request.Method = WebRequestMethods.Http.Get;

            //// Get the response.
            //WebResponse response = request.GetResponse();

            // Read the response
            string queryString = request;

            var parts = queryString.Split('&');
            this.Token = parts[1].Substring(parts[1].IndexOf('=') + 1);
            this.TokenSecret = parts[0].Substring(parts[0].IndexOf('=') + 1);
            return request;

        }