def __init__(self, oauth_version, consumer_key, consumer_secret, **kwargs):
self.oauth_version = oauth_version<EOL>data = {}<EOL>if kwargs.get('<STR_LIT>'):<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>self.from_file = kwargs.get('<STR_LIT>')<EOL>data = get_data(self.from_file)<EOL>vars(self).update(data)<EOL><DEDENT>else:<EOL><INDENT>self.consumer_key = consumer_key<EOL>self.consumer_secret = consumer_secret<EOL><DEDENT>vars(self).update(kwargs)<EOL>self.oauth_version = oauth_version<EOL>self.callback_uri = vars(self).get('<STR_LIT>',CALLBACK_URI)<EOL>if self.oauth_version == '<STR_LIT>':<EOL><INDENT>service_params = {<EOL>'<STR_LIT>': self.consumer_key,<EOL>'<STR_LIT>' : self.consumer_secret,<EOL>'<STR_LIT>': services[self.oauth_version]['<STR_LIT>']<EOL>}<EOL><DEDENT>else:<EOL><INDENT>service_params = {<EOL>'<STR_LIT>': self.consumer_key,<EOL>'<STR_LIT>': self.consumer_secret<EOL>}<EOL><DEDENT>service_params.update({<EOL>'<STR_LIT:name>' : '<STR_LIT>',<EOL>'<STR_LIT>' : services[self.oauth_version]['<STR_LIT>'],<EOL>'<STR_LIT>' : services[self.oauth_version]['<STR_LIT>'],<EOL>'<STR_LIT>': vars(self).get('<STR_LIT>',None)<EOL>})<EOL>self.oauth = services[oauth_version]['<STR_LIT>'](**service_params)<EOL>if vars(self).get('<STR_LIT>') and vars(self).get('<STR_LIT>') and vars(self).get('<STR_LIT>'):<EOL><INDENT>if not self.token_is_valid():<EOL><INDENT>data.update(self.refresh_access_token())<EOL><DEDENT><DEDENT>elif vars(self).get('<STR_LIT>') and vars(self).get('<STR_LIT>') and vars(self).get('<STR_LIT>'):<EOL><INDENT>if not self.token_is_valid():<EOL><INDENT>data.update(self.refresh_access_token())<EOL><DEDENT><DEDENT>else:<EOL><INDENT>data.update(self.handler()) <EOL><DEDENT>if self.oauth_version == '<STR_LIT>':<EOL><INDENT>self.session = self.oauth.get_session((self.access_token, self.access_token_secret))<EOL><DEDENT>else:<EOL><INDENT>self.session = self.oauth.get_session(token=self.access_token)<EOL><DEDENT>write_data(data, vars(self).get('<STR_LIT>','<STR_LIT>'))<EOL>
consumer_key : client key
consumer_secret : client secret
access_token : access token
access_token_secret : access token secret
from_file : file containing the credentials
base_url : Base url