def _sync_members(self): if self._members_dirty: create_google_api().list_sync(self.username, self._members)
import pprint import os import sys import uuid from stjornbord_google_api import GoogleAPICredentialException os.environ['DJANGO_SETTINGS_MODULE'] = 'stjornbord.settings' from stjornbord import settings from stjornbord.utils import create_google_api # https://developers.google.com/admin-sdk/directory/v1/guides/authorizing SCOPE = ["https://www.googleapis.com/auth/admin.directory.group", ] g = create_google_api() def fetch_nonexistent_list(): try: return g.list_members(str(uuid.uuid4())) is None except GoogleAPICredentialException, e: return False def main(): # See if we're already authenticated if not fetch_nonexistent_list(): g.authenticate(settings.GOOGLE_SECRETS, SCOPE) if fetch_nonexistent_list(): print "Authentication tokens are valid, test query was successful." else:
def get_members(self): if self._members is None: self._members = create_google_api().list_members(self.username) return self._members