static private String GenerateSignedUrl(String baseRequestTokenUrl, String method, OAuthConsumerContext context, OAuthToken token)
        {
            String normalizedUrl;
            String normalizedRequestParameters;

            var oAuth = new OAuthBase();

            string nonce = oAuth.GenerateNonce();
            string timeStamp = oAuth.GenerateTimeStamp();
            string sig = oAuth.GenerateSignature(   new Uri(baseRequestTokenUrl),
                                                    context.ConsumerKey, context.ConsumerSecret,
                                                    token == null ? string.Empty : token.TokenKey, token == null ? string.Empty : token.TokenSecret,
                                                    method.ToString(), timeStamp, nonce,
                                                    context.SignatureMethod,
                                                    out normalizedUrl, out normalizedRequestParameters);

            //
            // The signature as self has to be encoded to be ensure that no not url compatibale characters 
            // will be used. The SHA1 hash can contain a bunch of this characters
            //
            sig = HttpUtility.UrlEncode(sig);

            var sb = new StringBuilder(normalizedUrl);

            sb.AppendFormat("?");
            sb.AppendFormat(normalizedRequestParameters);
            sb.AppendFormat("&oauth_signature={0}", sig);

            return sb.ToString();
        }
        public String GetOAuthAuthorizationHeader(String resourceUrl, OAuthConsumerContext conContext, OAuthToken accessToken, Dictionary<String, String> parameter, String method)
        {
            var oAuth = new OAuthBase();

            String normalizedUrl;
            String normalizedRequestParameters;

            var timestamp = oAuth.GenerateTimeStamp();
            var nonce = oAuth.GenerateNonce();
            var signature = oAuth.GenerateSignature(new Uri(resourceUrl),
                                                    conContext.ConsumerKey, conContext.ConsumerSecret,
                                                    accessToken == null ? string.Empty : accessToken.TokenKey, accessToken == null ? string.Empty : accessToken.TokenSecret,
                                                    method, timestamp, nonce,
                                                    conContext.SignatureMethod,
                                                    out normalizedUrl, out normalizedRequestParameters);
            signature = HttpUtility.UrlEncode(signature);

            var sb = new StringBuilder("OAuth");
            sb.Append(", oauth_version=1.0");
            sb.AppendFormat(", oauth_nonce={0}", nonce);
            sb.AppendFormat(", oauth_timestamp={0}", timestamp);
            sb.AppendFormat(", oauth_consumer_key={0}", conContext.ConsumerKey);
            if (accessToken != null)
            {
                sb.AppendFormat(", , oauth_token={0}", accessToken.TokenKey);
            }
            sb.Append(", oauth_signature_method=\"HMAC-SHA1\"");
            sb.AppendFormat(", oauth_signature={0}", signature);
            
            return sb.ToString();
        }
        public virtual WebRequest CreateWebRequest(String url, String method, ICredentials credentials, Object context, OAuthConsumerContext conContext, OAuthToken accessToken, Dictionary<String, String> parameter)
        {
            // generate the signed url
            String signedUrl = GetProtectedResourceUrl(url, conContext, accessToken, parameter, method);

            // generate the web request as self
            return CreateWebRequest(signedUrl, method, credentials, false, context);
        }
        static public String GenerateAuthorizationUrl(String baseAuthorizeUrl, String callbackUrl, OAuthToken requestToken)
        {
            var sb = new StringBuilder(baseAuthorizeUrl);

            sb.AppendFormat("?oauth_token={0}", requestToken.TokenKey);
            sb.AppendFormat("&oauth_callback={0}", OAuthBase.UrlEncode(callbackUrl, '.'));

            return sb.ToString();
        }
        static public String GenerateSignedUrl(String baseResourceUrl, String method, OAuthConsumerContext context, OAuthToken token, Dictionary<String, String> urlParameter)
        {            
            var sb = new StringBuilder(baseResourceUrl);

            if (urlParameter != null)
            {
                sb.Append('?');

                foreach (KeyValuePair<String, String> kvp in urlParameter)
                {   
                    if ( sb[sb.Length - 1] == '?' )
                        sb.AppendFormat("{0}={1}", kvp.Key, OAuthBase.UrlEncode(kvp.Value));
                    else
                        sb.AppendFormat("&{0}={1}", kvp.Key, OAuthBase.UrlEncode(kvp.Value));
                }
            }                        

            return GenerateSignedUrl(sb.ToString(), method, context, token);
        }
 static public String GenerateAccessTokenUrl(String baseAccessTokenUrl, OAuthConsumerContext context, OAuthToken requestToken)
 {
     return GenerateSignedUrl(baseAccessTokenUrl, WebRequestMethodsEx.Http.Get, context, requestToken);            
 }
 public String GetSignedUrl(String resourceUrl, OAuthConsumerContext conContext, OAuthToken accessToken, Dictionary<String, String> parameter)
 {
     return OAuthUrlGenerator.GenerateSignedUrl(resourceUrl, WebRequestMethodsEx.Http.Post, conContext, accessToken, parameter);
 }
 public String GetProtectedResourceUrl(String resourceUrl, OAuthConsumerContext conContext, OAuthToken accessToken, Dictionary<String, String> parameter, String webMethod)
 {
     // build url
     return OAuthUrlGenerator.GenerateSignedUrl(resourceUrl, webMethod, conContext, accessToken, parameter);            
 }
        public OAuthToken GetAccessToken(OAuthServiceContext svcContext, OAuthConsumerContext conContext, OAuthToken requestToken)
        {
            String url = OAuthUrlGenerator.GenerateAccessTokenUrl(svcContext.AccessTokenUrl, conContext, requestToken);

            return GetToken(url);
        }
 internal DropBoxRequestToken(OAuthToken realToken)
 {
     RealToken = realToken;
 }
 public DropBoxToken(OAuthToken token, DropBoxBaseTokenInformation baseCreds)
     : base(token.TokenKey, token.TokenSecret)
 {
     BaseTokenInformation = baseCreds;
 }
 internal GoogleDocsRequestToken(OAuthToken realToken)
 {
     RealToken = realToken;
 }
 public GoogleDocsToken(OAuthToken token, String consumerKey, String consumerSecret)
     : this(token.TokenKey, token.TokenSecret, consumerKey, consumerSecret)
 {
 }