public OauthAccessToken RevokeAccessToken(OauthAccessToken token)
        {
            Dictionary<string, string> p = new Dictionary<string, string>();
            p["token"] = token.AccessToken;

            return ExecuteTokenRequest(p, token, OauthBaseUrl + "/revoke", true);
        }
        private OauthAccessToken ExecuteTokenRequest(Dictionary<string, string> p, Authentication authentication, string url, bool revoke = false)
        {
            OauthAccessToken token = null;

            if (authentication == null)
            {
                authentication = GetDefaultAuthentication();
            }

            string requestBody = BuildParamString(p, "POST");

            string privateKey = authentication.PrivateApiKey;
            string publicKey = authentication.PublicApiKey;
            string signature = JwsEncode(url, requestBody, authentication);

            HttpWebRequest request = CreateWebRequest(url, requestBody, "POST", privateKey, publicKey);
            request.ContentType = "application/x-www-form-urlencoded";
            request.AllowAutoRedirect = false;

            try
            {
                string result = ExecuteRequest(request, requestBody, signature);

                if (!revoke)
                {
                    token = (OauthAccessToken)JsonConvert.DeserializeObject(result, typeof(OauthAccessToken));
                }
                else
                {
                    OauthRevokeAccessToken t = (OauthRevokeAccessToken)JsonConvert.DeserializeObject(result, typeof(OauthRevokeAccessToken));
                    token = new OauthAccessToken();
                    token.AccessToken = t.TokenRevoked;
                }

                token.PrivateApiKey = privateKey;
                token.PublicApiKey = publicKey;
            }
            catch (InvalidRequestException ex)
            {
                JObject o = (JObject)ex.ErrorData;

                string error = o.GetValue("error").Value<string>();
                string errorDescription = o.GetValue("error_description").Value<string>();
                throw new OauthException(error, errorDescription);
            }

            return token;
        }
 public OauthAccessToken RefreshAccessToken(OauthAccessToken token)
 {
     Dictionary<string, string> p = new Dictionary<string, string>();
     p["grant_type"] = "refresh_token";
     p["refresh_token"] = token.RefreshToken;
     return ExecuteTokenRequest(p, token, OauthBaseUrl + "/token");
 }