@@ -226,13 +226,15 @@ def employee_client(username=None,
226226 if access_token is None :
227227 access_token = settings .get ('access_token' )
228228
229- user_id = settings .get ('user_id ' )
229+ user_id = settings .get ('userid ' )
230230
231231 # Assume access_token is valid for now, user has logged in before at least.
232232 if access_token and user_id :
233233 auth = slauth .EmployeeAuthentication (user_id , access_token )
234234 return EmployeeClient (auth = auth , transport = transport )
235235 else :
236+ # This is for logging in mostly.
237+ LOGGER .info ("No access_token or userid found in settings, creating a No Auth client for now." )
236238 return EmployeeClient (auth = None , transport = transport )
237239
238240
@@ -670,7 +672,7 @@ def authenticate_with_password(self, username, password, security_token=None):
670672
671673
672674 self .settings ['softlayer' ]['access_token' ] = auth_result ['hash' ]
673- self .settings ['softlayer' ]['userId ' ] = str (auth_result ['userId' ])
675+ self .settings ['softlayer' ]['userid ' ] = str (auth_result ['userId' ])
674676 # self.settings['softlayer']['refresh_token'] = tokens['refresh_token']
675677
676678 config .write_config (self .settings , self .config_file )
@@ -691,8 +693,6 @@ def authenticate_with_hash(self, userId, access_token):
691693 def refresh_token (self , userId , auth_token ):
692694 """Refreshes the login token"""
693695
694- self .auth = None
695-
696696 # Go directly to base client, to avoid infite loop if the token is super expired.
697697 auth_result = BaseClient .call (self , 'SoftLayer_User_Employee' , 'refreshEncryptedToken' , auth_token , id = userId )
698698 if len (auth_result ) > 1 :
@@ -719,7 +719,7 @@ def call(self, service, method, *args, **kwargs):
719719 return BaseClient .call (self , service , method , * args , ** kwargs )
720720 except exceptions .SoftLayerAPIError as ex :
721721 if ex .faultCode == "SoftLayer_Exception_EncryptedToken_Expired" :
722- userId = self .settings ['softlayer' ].get ('userId ' )
722+ userId = self .settings ['softlayer' ].get ('userid ' )
723723 access_token = self .settings ['softlayer' ].get ('access_token' )
724724 LOGGER .warning ("Token has expired, trying to refresh. %s" , ex .faultString )
725725 self .refresh_token (userId , access_token )
0 commit comments