示例#1
0
 def create_gtasks_service_proxy(cls):
     auth_service = AuthenticationService()
     authorized_http = auth_service.authenticate_connection()
     gtasks_service_proxy = apiclient.discovery.build("tasks", "v1",
         http=authorized_http)
     
     return gtasks_service_proxy
示例#2
0
    def start(self):
        """
        Begin the CogGrinder application by authenticating the user, and then
        creating and starting the controller for the primary app view.
        """
        main_controller = TaskTreeWindowController()

        # With the UI built, attempt to access the authentication credentials
        # for the user. If those credentials cannot be found, prompt the user
        # for permission to proceed with the Google OpenID authentication 
        # process.
        auth_service = AuthenticationService()
        while not auth_service.has_valid_credentials():
            # Local credentials are either missing or invalid, notify the user
            # that an attempt will be made to authenticate them.
            auth_dialog_controller = AuthenticationDialogViewController(main_controller)
            
            user_choice = auth_dialog_controller.show_dialog()
            
            if user_choice == Gtk.ResponseType.CANCEL:
                # User has canceled the authentication process, and the 
                # app cannot proceed.
                main_controller.view.destroy()
                return
            else:
                # Delete the old dialog.
                auth_dialog_controller.delete_dialog()
                
        # Create an authenticated connection for use in communicating with 
        # the Google Task services. If the user doesn't have valid local
        # credentials, this will begin with running them 
        # through the Google Accounts authentication process.
        auth_http_connection = auth_service.authenticate_connection()
        
        gtasks_service_proxy = GoogleTasksServiceProxy(auth_http_connection)
        
        tasklist_service = gtasks_service_proxy.create_tasklist_service()
        task_service = gtasks_service_proxy.create_task_service()        
        
        tasktree_service = TaskTreeService()
        tasktree_service.tasklist_service = tasklist_service
        tasktree_service.task_service = task_service
        
        main_controller.tasktree_service = tasktree_service
        main_controller.refresh_task_data()
        main_controller.show()
        
        Gtk.main()