def _tryToGetAccessKeyFromAPIKey(self): (url, requestToken) = self._smugmugOauthRequestToken() self._userAuthorizeAtSmugmug(url) access_token = self._smugmugOauthGetAccessToken(requestToken) FileUtil.writeDictToYaml(access_token, self.accessKeyDir) return access_token
def getSmug(self): # try to read self._loadAPIKey() try: access_token = FileUtil.readYamlToDict(self.accessKeyDir) if access_token is None: access_token = self._tryToGetAccessKeyFromAPIKey() except FileExistsError: access_token = self._tryToGetAccessKeyFromAPIKey() self.access_token = access_token return self._smugmugOauthUseAccessToken(access_token)
def _loadAPIKey(self): keys = FileUtil.readYamlToDict(self.apiKeyDir) self.api_key = keys["API Key"] self.oauth_secret = keys['Oauth Secret'] self.app_name = keys["App Name"]