diff --git a/resources/lib/connect/connectionmanager.py b/resources/lib/connect/connectionmanager.py index af900592..999993b5 100644 --- a/resources/lib/connect/connectionmanager.py +++ b/resources/lib/connect/connectionmanager.py @@ -669,6 +669,7 @@ class ConnectionManager(object): credentials = self.credentialProvider.getCredentials() credentials['ConnectAccessToken'] = result['AccessToken'] credentials['ConnectUserId'] = result['User']['Id'] + credentials['ConnectUser'] = result['User']['DisplayName'] self.credentialProvider.getCredentials(credentials) # Signed in self._onConnectUserSignIn(result['User']) diff --git a/resources/lib/connectmanager.py b/resources/lib/connectmanager.py index 09970fa6..9c8cdf27 100644 --- a/resources/lib/connectmanager.py +++ b/resources/lib/connectmanager.py @@ -201,15 +201,17 @@ class ConnectManager(object): else: raise RuntimeError("User is not authenticated") - def update_token(self, servers, server): + def update_token(self, server): credentials = self._connect.credentialProvider.getCredentials() - updated_server = self._connect.credentialProvider.addOrUpdateServer(servers, server) + self._connect.credentialProvider.addOrUpdateServer(credentials['Servers'], server) for server in self.get_state()['Servers']: - if server['Id'] == updated_server['Id']: - # Update token saved in current state - server.update(updated_server) + for cred_server in credentials['Servers']: + if server['Id'] == cred_server['Id']: + # Update token saved in current state + server.update(server) + log.info(self.get_state()) # Update the token in data.txt self._connect.credentialProvider.getCredentials(credentials) diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index 58b9f1bb..40cfe3e2 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -101,7 +101,7 @@ class InitialSetup(object): # Update token server['UserId'] = settings('userId') or None server['AccessToken'] = settings('token') or None - self.connectmanager.update_token(current_state['Servers'], server) + self.connectmanager.update_token(server) server_address = self.connectmanager.get_address(server) self._set_server(server_address, server)