protected virtual WebToken ExtractSecurityTokenFromResponse(ProtocolResponse oauthResponse)
        {
            string lifetime = oauthResponse.BodyParameters["wrap_access_token_expires_in"];
            string accessTokenString = oauthResponse.BodyParameters["wrap_access_token"];

            var token = new WebToken(accessTokenString);
            token.Expiration.AddSeconds(int.Parse(lifetime));
            
            return token;
        }
        protected string RequestAccessToken()
        {
            if (_cachedToken == null || _cachedToken.Expiration < DateTime.Now.AddMinutes(1))
            {
                Dictionary<string, string> bodyParameters = CreateAccessTokenRequestParameters();

                UrlParts url = new UrlParts(TokenEndpoint)
                {
                    Path = TokenEndpoint.AbsolutePath
                };

                ProtocolRequest oauthRequest = CreateProtocolRequest(url, bodyParameters);

                ProtocolResponse oauthResponse = _httpClient.SendRequest(oauthRequest);

                _cachedToken = ExtractSecurityTokenFromResponse(oauthResponse);
            }

            return _cachedToken.Token;
        }
        private string RequestAccessToken()
        {
            if (_cachedToken == null || _cachedToken.Expiration < DateTime.Now.AddMinutes(1))
            {
                Dictionary<string, string> parameters = CreateAccessTokenRequestParameters();
                ProtocolRequest oauthRequest = CreateProtocolRequest(parameters);
                ProtocolResponse oauthResponse = _httpClient.SendRequest(oauthRequest);

                _cachedToken = ExtractSecurityTokenFromResponse(oauthResponse);
            }

            return _cachedToken.Token;
        }