code: def _generateForTokenSecurity(self,
                                    username,
                                    password,
                                    referer=None,
                                    tokenUrl=None,
                                    expiration=None,
                                    proxy_url=None,
                                    proxy_port=None):
          
          if referer is None:
              referer = self._referer_url
          if tokenUrl is None:
              tokenUrl  = self._token_url
  
          query_dict = {'username': self._username,
                        'password': self._password,
                        'expiration': str(_defaultTokenExpiration),
                        'referer': referer,
                        'f': 'json'}
          if expiration is not None:
              query_dict['expiration'] = str(expiration)
          self._token_created_on = datetime.datetime.now()
          token = self._post(url=tokenUrl,
                                param_dict=query_dict,
                                securityHandler=None,
                                proxy_port=self._proxy_port,
                                proxy_url=self._proxy_url)
          if 'error' in token:
              self._token = None
              return token
  
  
          self._token_expires_on = datetime.datetime.fromtimestamp(token['expires'] / 1000) - \
              datetime.timedelta(seconds=10)
          if "token" not in token:
              self._token = None
              return None
          else:
              httpPrefix = self._url
              if token['ssl'] == True:
                  httpPrefix = self._surl
              self._token = token['token']
              return token['token'], httpPrefix
docs: generates a token for a feature service