Python Forum

Full Version: Loging in users google account
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am Stuck. So, What I am doing is:
I have python script which should run and download the contents of google drive from all the users. My code when runs it download the files from my google drive not from other users. My question is that:

I am not sure how should I login as a user in google using python. Can anyone please help.
Following are my methods which are triggered when logging in:
def get_credentials():
   		home_dir = os.path.expanduser('~')
		credential_dir = os.path.join(home_dir, '.credentials')
		if not os.path.exists(credential_dir):
			os.makedirs(credential_dir)
		credential_path = os.path.join(credential_dir,
                                   'admin-directory_v1-python-quickstart.json')

		store = Storage(credential_path)
		credentials = store.get()
		if not credentials or credentials.invalid:
			flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
			flow.user_agent = APPLICATION_NAME
			if flags:
				credentials = tools.run_flow(flow, store, flags)
			else: # Needed only for compatibility with Python 2.6
				credentials = tools.run(flow, store)
			print('Storing credentials to ' + credential_path)
		return credentials

credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('admin', 'directory_v1', http=http)
Then I user 'service' object to create users or download contents from google drive but this service object os for my google account not for any other user. Can anyone throw some light on it?

Thanks,
Aman