def renew_access_token(access_token = nil, access_secret = nil, session_handle = nil)
      access_token   ||= @atoken
      access_secret  ||= @asecret
      session_handle ||= @session_handle

      old_token = ::OAuth::RequestToken.new(consumer, access_token, access_secret)

      # Underlying oauth consumer accepts body params and headers for request via positional params - explicit nilling of 
      #  body parameters allows for correct position for headers
      access_token = old_token.get_access_token({
        :oauth_session_handle => session_handle,
        :token                => old_token
      }, nil, @base_headers)

      update_attributes_from_token(access_token)
    rescue ::OAuth::Unauthorized => e
      # If the original access token is for some reason invalid an OAuth::Unauthorized could be raised.
      # In this case raise a XeroGateway::OAuth::TokenInvalid which can be captured by the caller.  In this
      # situation the end user will need to re-authorize the application via the request token authorization URL
      raise XeroGateway::OAuth::TokenInvalid.new(e.message)
    end
def renew_access_token(access_token = nil, access_secret = nil, session_handle = nil)
      access_token   ||= @atoken
      access_secret  ||= @asecret
      session_handle ||= @session_handle

      old_token = ::OAuth::RequestToken.new(consumer, access_token, access_secret)

      # Underlying oauth consumer accepts body params and headers for request via positional params - explicit nilling of 
      #  body parameters allows for correct position for headers
      access_token = old_token.get_access_token({
        :oauth_session_handle => session_handle,
        :token                => old_token
      }, nil, @base_headers)

      update_attributes_from_token(access_token)
    rescue ::OAuth::Unauthorized => e
      # If the original access token is for some reason invalid an OAuth::Unauthorized could be raised.
      # In this case raise a XeroGateway::OAuth::TokenInvalid which can be captured by the caller.  In this
      # situation the end user will need to re-authorize the application via the request token authorization URL
      raise XeroGateway::OAuth::TokenInvalid.new(e.message)
    end
Renewing access tokens only works for Partner applications