def getToken(self, perms="read", browser="lynx"):
        
        # see if we have a saved token
        token = self.__getCachedToken()

        # see if it's valid
        if token != None:
            rsp = self.auth_checkToken(api_key=self.apiKey, auth_token=token)
            if rsp['stat'] != "ok":
                token = None
            else:
                # see if we have enough permissions
                tokenPerms = rsp.auth[0].perms[0].elementText
                if tokenPerms == "read" and perms != "read": token = None
                elif tokenPerms == "write" and perms == "delete": token = None

        # get a new token if we need one
        if token == None:
            # get the frob
            rsp = self.auth_getFrob(api_key=self.apiKey)
            self.testFailure(rsp)

            frob = rsp.frob[0].elementText

            # validate online
            os.system("%s '%s'" % (browser, self.__getAuthURL(perms, frob)))

            # get a token
            rsp = self.auth_getToken(api_key=self.apiKey, frob=frob)
            self.testFailure(rsp)

            token = rsp.auth[0].token[0].elementText

            # store the auth info for next time
            self.__setCachedToken(rsp.xml)

        return token

########################################################################
# App functionality
########################################################################
Get a token either from the cache, or make a new one from the
dataset/ETHPy150Open sightmachine/SimpleCV/SimpleCV/MachineLearning/query_imgs/flickrapi2.py/FlickrAPI.getToken