code: def get_user_api_key(self, username, create=True):
          
          retval = self._database.users.find_one({"username": username}, {"apikey": 1})
          if "apikey" not in retval and create:
              apikey = self.generate_api_key()
              self._database.users.update_one({"username": username}, {"$set": {"apikey": apikey}})
          elif "apikey" not in retval:
              apikey = None
          else:
              apikey = retval["apikey"]
          return apikey
docs: Get the API key of a given user.
          API keys are generated on demand.
          :param username:
          :param create: Create the API key if none exists yet
          :return: the API key assigned to the user, or None if none exists and create is False.