<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _generateForOAuthSecurity(self, client_id, secret_id, token_url=None):
 """ generates a token based on the OAuth security model """

        grant_type="client_credentials"
        if token_url is None:
            token_url = "https://www.arcgis.com/sharing/rest/oauth2/token"
        params = {
            "client_id" : client_id,
            "client_secret" : secret_id,
            "grant_type":grant_type,
            "f" : "json"
        }
        token = self._post(url=token_url,
                              param_dict=params,
                              securityHandler=None,
                              proxy_port=self._proxy_port,
                              proxy_url=self._proxy_url)
        if 'access_token' in token:
            self._token = token['access_token']
            self._expires_in = token['expires_in']
            self._token_created_on = datetime.datetime.now()
            self._token_expires_on = self._token_created_on + datetime.timedelta(seconds=int(token['expires_in']))
            self._valid = True
            self._message = "Token Generated"
        else:
            self._token = None
            self._expires_in = None
            self._token_created_on = None
            self._token_expires_on = None
            self._valid = False
            self._message = token