def request_tokens(self):
url = '<STR_LIT>'<EOL>params = {'<STR_LIT>': '<STR_LIT>', '<STR_LIT:code>': self.authorization_code,<EOL>'<STR_LIT>': self.api_key}<EOL>try:<EOL><INDENT>request = requests.post(url, params=params)<EOL><DEDENT>except RequestException:<EOL><INDENT>logger.warn("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>return<EOL><DEDENT>if request.status_code == requests.codes.ok:<EOL><INDENT>self.access_token = request.json()['<STR_LIT>']<EOL>self.refresh_token = request.json()['<STR_LIT>']<EOL>self.write_tokens_to_file()<EOL>self.pin = None<EOL><DEDENT>else:<EOL><INDENT>logger.warn('<STR_LIT>'<EOL>'<STR_LIT>' + str(request.status_code))<EOL>return<EOL><DEDENT>
Method to request API tokens from ecobee