Skip to content

token_login() method doesn't change the logged_in attribute and doesn't verify a token #169

Closed

Description

@skokovsergey

I see 2 issues with token_login() method

  1. token_login() method doesn't change logged_in attrubte to true. As a result, the token won't be refreshed in run() method.
  2. token_login() method doesn't verify token expiration or refresh it. I would expect an exception if the token had expired (without refreshToken) or if an error happened during refresh.
    def token_login(self, token, refresh_token=None):
        token_json = {
            "token": token,
            "refreshToken": refresh_token,
        }

        self.__save_token(token_json)
        self.__load_configuration()

    def run(self):
        self.stopped = False
        while not self.stopped:
            try:
                check_time = time()
                if check_time >= self.token_info["exp"] and self.logged_in:
                    if self.token_info["refreshToken"]:
                        self.refresh()
                    else:
                        logger.error("No username or password provided!")
                sleep(1)
            except Exception as e:
                logger.exception(e)
                break
            except KeyboardInterrupt:
                break

Activity

  1. linked a pull request that will close this issueUpdated REST Client for TB 4.0.0 #175on Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions