docs: def _generateForTokenSecurity(self,
                                    username, password,
                                    tokenUrl,
                                    expiration=None,
                                    client='requestip'):
          """ generates a token for a feature service """
  
          query_dict = {'username': username,
                        'password': password,
                        'expiration':str(_defaultTokenExpiration),
                        'client': client,
                        'f': 'json'}
          if client == "referer":
              query_dict['referer'] = self._referer_url
          if expiration is not None:
              query_dict['expiration'] = expiration
  
          secHandler = None
          if self.cookiejar is not None:
              secHandler = self
              if secHandler is not None:
                  secHandler._method = "HANDLER"
          token = self._post(url=tokenUrl,
                             param_dict=query_dict,
                             securityHandler=secHandler,
                             proxy_port=self._proxy_port,
                             proxy_url=self._proxy_url)
          if self.cookiejar is not None:
              if secHandler is not None:
                  secHandler._method = "TOKEN"
          if 'error' in token:
              self._token = None
              self._token_created_on = None
              self._token_expires_on = None
              self._expires_in = None
  
              return token
          elif 'status' in token:
              self._token = None
              self._token_created_on = None
              self._token_expires_on = None
              self._expires_in = None
              #print token['message']
              return token
  
          else:
              self._token = token['token']
              self._token_created_on = datetime.datetime.now()
              self._token_expires_on = datetime.datetime.fromtimestamp(token['expires'] /1000) - \
                  datetime.timedelta(seconds=1)
              self._expires_in = (self._token_expires_on - self._token_created_on).total_seconds()
              return token['token']