def handleLogin(self, message): if not message: return if message['state'][0] != self.state: logger.warn("OAUTH state mismatch") return logger.debug("Handling CREST login with: %s", message) if 'access_token' in message: # implicit eve = copy.deepcopy(self.eve) eve.temptoken_authorize(access_token=message['access_token'][0], expires_in=int(message['expires_in'][0])) self.ssoTimer = threading.Timer(int(message['expires_in'][0]), self.logout) self.ssoTimer.start() eve() info = eve.whoami() logger.debug("Got character info: %s", info) self.implicitCharacter = CrestChar(info['CharacterID'], info['CharacterName']) self.implicitCharacter.eve = eve # self.implicitCharacter.fetchImage() wx.PostEvent(self.mainFrame, GE.SsoLogin(type=CrestModes.IMPLICIT)) elif 'code' in message: eve = copy.deepcopy(self.eve) eve.authorize(message['code'][0]) eve() info = eve.whoami() logger.debug("Got character info: %s", info) # check if we have character already. If so, simply replace refresh_token char = self.getCrestCharacter(int(info['CharacterID'])) if char: char.refresh_token = eve.refresh_token else: char = CrestChar(info['CharacterID'], info['CharacterName'], eve.refresh_token) char.eve = eve self.charCache[int(info['CharacterID'])] = char eds_queries.save(char) wx.PostEvent(self.mainFrame, GE.SsoLogin(type=CrestModes.USER)) self.stopServer()
def handleLogin(self, ssoInfo): auth_response = json.loads(base64.b64decode(ssoInfo)) # We need to preload the ESI Security object beforehand with the auth response so that we can use verify to # get character information # init the security object esisecurity = EsiSecurityProxy(sso_url=config.ESI_AUTH_PROXY) esisecurity.update_token(auth_response) # we get the character information cdata = esisecurity.verify() print(cdata) currentCharacter = self.getSsoCharacter(cdata['CharacterName']) if currentCharacter is None: currentCharacter = SsoCharacter(cdata['CharacterID'], cdata['CharacterName'], config.getClientSecret()) currentCharacter.esi_client = Esi.genEsiClient(esisecurity) Esi.update_token( currentCharacter, auth_response) # this also sets the esi security token eos.db.save(currentCharacter) wx.PostEvent(self.mainFrame, GE.SsoLogin(character=currentCharacter))
def handleLogin(self, message): # we already have authenticated stuff for the auto mode if (self.settings.get('ssoMode') == SsoMode.AUTO): ssoInfo = message['SSOInfo'][0] auth_response = json.loads(base64.b64decode(ssoInfo)) else: # otherwise, we need to fetch the information auth_response = self.auth(message['code'][0]) res = self._session.get(self.oauth_verify, headers=self.get_oauth_header( auth_response['access_token'])) if res.status_code != 200: raise APIException(self.oauth_verify, res.status_code, res.json()) cdata = res.json() print(cdata) currentCharacter = self.getSsoCharacter(cdata['CharacterName']) if currentCharacter is None: currentCharacter = SsoCharacter(cdata['CharacterID'], cdata['CharacterName'], config.getClientSecret()) Esi.update_token(currentCharacter, auth_response) eos.db.save(currentCharacter) wx.PostEvent(self.mainFrame, GE.SsoLogin(character=currentCharacter))
def handleLogin(self, message): auth_response, data = self.auth(message['code']) currentCharacter = self.getSsoCharacter(data['name']) sub_split = data["sub"].split(":") if (len(sub_split) != 3): raise GenericSsoError("JWT sub does not contain the expected data. Contents: %s" % data["sub"]) cid = sub_split[-1] if currentCharacter is None: currentCharacter = SsoCharacter(cid, data['name'], config.getClientSecret()) Esi.update_token(currentCharacter, auth_response) eos.db.save(currentCharacter) wx.PostEvent(self.mainFrame, GE.SsoLogin(character=currentCharacter))