def CreateClient(self, email, password): """Create a Documents List Client.""" client = gdata.docs.client.DocsClient(source=AppConfig.APP_NAME) client.http_client.debug = AppConfig.DEBUG # Authenticate the user with CLientLogin, OAuth, or AuthSub. try: client.client_login(email, password, AppConfig.APP_NAME) except gdata.client.BadAuthentication: exit('Invalid user credentials given.') except gdata.client.Error: exit('Login Error') return client
def CreateClient(self, email, password): """Create a Documents List Client.""" client = gdata.docs.client.DocsClient(source=AppConfig.APP_NAME) client.http_client.debug = AppConfig.DEBUG # Authenticate the user with CLientLogin, OAuth, or AuthSub. try: client.client_login(email, password, AppConfig.APP_NAME) except gdata.client.BadAuthentication: exit('Invalid user credentials given.') except gdata.client.Error: exit('Login Error') return client
def connect_client(): # Credentials. username = '******' gaspw = 'qjahvuisfmeyteve' # Application details. source = 'scrabble_helper' # Make a client and connect to Google. client = gdata.docs.client.DocsClient() client.client_login(username, gaspw, source) # Done. return client
def create_client(): client = gdata.docs.client.DocsClient(source=SampleConfig.APP_NAME) try: if USER is None: gdata.sample_util.authorize_client( client, 1, service=client.auth_service, source=client.source, scopes=client.auth_scopes ) else: client.client_login(USER, PASS, source=client.source, service=client.auth_service) except gdata.client.BadAuthentication: exit("Invalid user credentials given.") except gdata.client.Error: exit("Login Error") return client
def login(i_name, i_password, i_app_name): """ Returns an authorized client and its cooresponding ClientLoginToken, given the credentials passed in i_name (string) : the email of the account to log in to i_password (string) : the password for the account to log in to i_app_name (str) : the name of the application that will use the login return : a 2-tuple where item one is the logged-in Document List client (gdata.docs.client.DocsClient) and item two is the ClientLoginToken, or None if logging in fails """ client = gdata.docs.client.DocsClient(source='Docs List App') client.ssl = True # Force all API requests through HTTPS client.http_client.debug = False # Set to True for debugging HTTP requests try: auth_token = client.client_login(i_name, i_password, i_app_name) return client, auth_token except: return None
def CreateClient(): """Create a Documents List Client.""" client = gdata.docs.client.DocsClient(source=SampleConfig.APP_NAME) client.http_client.debug = SampleConfig.DEBUG # Authenticate the user with CLientLogin, OAuth, or AuthSub. try: client.client_login('*****@*****.**', 'vum-v0d7xaju', source=None, service='writely') doc = client.GetAllResources(): acl_entry = gdata.docs.data.AclEntry( scope=gdata.acl.data.AclScope(value='*****@*****.**', type='user'), role=gdata.acl.data.AclRole(value='reader'), ) client.AddAclEntry(doc, acl_entry, send_notification=False) except gdata.client.BadAuthentication: exit('Invalid user credentials given.') except gdata.client.Error: exit('Login Error') return client
def CreateClient(): """Create a Documents List Client.""" client = gdata.docs.client.DocsClient(source=SampleConfig.APP_NAME) client.http_client.debug = SampleConfig.DEBUG client.client_login(GOOGLE_USER, GOOGLE_PASS, source=client.source, service=client.auth_service) return client
name = "Project" kind = "spreadsheet" user = "******" password = "******" #Checks if kind == "presentation" or kind == "document" or kind == "spreadsheet": pass else: print "Warning: Invalid input. Closing Program..." sys.exit() #Logs in client = gdata.docs.client.DocsClient(source='TestDoc') client.http_client.debug = False client.client_login(email=user, password=password, source="TestDoc", service="writely") #Creates our doc document = gdata.docs.data.Resource(type=kind, title=name) document = client.CreateResource(document) key = document.GetId().split("%3A")[1] print "Key = %s" % key #Prints url if kind == "presentation" or kind == "document": url = "https://docs.google.com/" + kind + "/d/" + key elif kind == "spreadsheet": url = "https://docs.google.com/spreadsheet/ccc?key=" + key else: url = "Unknown URL"