'Get a token either from the cache, or make a new one from the
frob.
This first attempts to find a token in the user\'s token cache on
disk.
If that fails (or if the token is no longer valid based on
flickr.auth.checkToken) a new frob is acquired.  The frob is
validated by having the user log into flickr (with lynx), and
subsequently a valid token is retrieved.
The newly minted token is then cached locally for the next run.
perms--"read", "write", or "delete"
browser--whatever browser should be used in the system() call'

def getToken(self, perms='read', browser='lynx'):

    token = self.__getCachedToken()
    if (token != None):
        rsp = self.auth_checkToken(api_key=self.apiKey, auth_token=token)
        if (rsp['stat'] != 'ok'):
            token = None
        else:
            tokenPerms = rsp.auth[0].perms[0].elementText
            if ((tokenPerms == 'read') and (perms != 'read')):
                token = None
            elif ((tokenPerms == 'write') and (perms == 'delete')):
                token = None
    if (token == None):
        rsp = self.auth_getFrob(api_key=self.apiKey)
        self.testFailure(rsp)
        frob = rsp.frob[0].elementText
        os.system(("%s    '%s'" % (browser, self.__getAuthURL(perms, frob))))
        rsp = self.auth_getToken(api_key=self.apiKey, frob=frob)
        self.testFailure(rsp)
        token = rsp.auth[0].token[0].elementText
        self.__setCachedToken(rsp.xml)
    return token
