Crystal03 / google-docs-fs

Automatically exported from code.google.com/p/google-docs-fs
GNU General Public License v2.0
0 stars 0 forks source link

Use stored credentials #50

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I've mailed about thie before, I woul like the option to add the 
credentialsfile to the commandline. This prevents the asking for a password, 
which is not a good thing in scripts.

Stef

Original issue reported on code.google.com by Stef...@gmail.com on 10 Mar 2011 at 9:02

GoogleCodeExporter commented 9 years ago
Does anyone have a work around? This plugin rocks.

Original comment by Greenlov...@gmail.com on 11 Mar 2011 at 4:21

GoogleCodeExporter commented 9 years ago
I've marked this as an enhancement.

If anyone wishes to do this, these are the modifications that are required:
  * Modify the gmount.py script to point to a pre-defined password file (stored under the user's home directory)
  * Add a command-line switch that can be passed into gmount.py, with an if block that will either load the password file for the password if the switch is detected; otherwise ask the user.

I hope that helps, if anyone wishes to put this feature in, let me know and I 
can put your changes in.

Cheers,
Scott W

Original comment by d38dm8nw81k1ng@gmail.com on 13 Mar 2011 at 1:48

GoogleCodeExporter commented 9 years ago
I should have some time over spring break in the next few weeks and can code 
python. I will look into it.

Original comment by Greenlov...@gmail.com on 14 Mar 2011 at 6:15

GoogleCodeExporter commented 9 years ago
Do you have any result yet?

In case you do not have time I'm also willing to do this. 

Original comment by Stef...@gmail.com on 28 Mar 2011 at 8:56

GoogleCodeExporter commented 9 years ago
Well to read a file in python I've found (in pseudocode):

def read_credentials(filename):
    f = open(filename)
    for lines in f:
        parameter = lines.split('=', 1)
        if paramter = 'email' do something:
          ......
        if parameter = 'password' do something else;

something like this.

Stef

Original comment by Stef...@gmail.com on 28 Mar 2011 at 10:23

GoogleCodeExporter commented 9 years ago
Change that code to:

key, value = line.split('=')
if key == 'email':
  email_address = value
if key == 'password':
  password = value
return email_address, password

And that should more or less cover you.

Original comment by d38dm8nw81k1ng@gmail.com on 30 Mar 2011 at 3:14

GoogleCodeExporter commented 9 years ago
Hi.

I've programmed the following:

#!/usr/bin/python
# -*- coding: utf-8 -*-
#

from optparse import OptionParser

def main():
        parser = OptionParser(usage="%prog [options]", version="%prog 0.1")
        parser.add_option("-p", "--credentials", dest="credentialsfile", help="Specifies the location of the file with credentails", default="")

        (options, args) = parser.parse_args()

        emailaddress=""
        password=""

        if len(options.credentialsfile) > 0:
            f = open(options.credentialsfile)
            for line in f:
                key, value = line.split('=')
                if key == 'email':
                    emailaddress = value
                elif key == 'password':
                    password = value

        if (len(emailaddress) > 0):
            print "email : " + emailaddress

        if (len(password) > 0):
            print "password : " + password

if __name__ == "__main__":
        main();

Howto integrate this?? In gmount.py and parse the email and the password to 
gFile.py as parameter?? This is insecure isn't it?
Any thoughts?

Original comment by Stef...@gmail.com on 8 Apr 2011 at 8:26

GoogleCodeExporter commented 9 years ago
Hi,

I've added the function readcredentials, which will look for credentials.

It's behavious does depend on the options given.

the following is possible:

gmount %mountpoint%

this will make it look for the cred file at the default location . I took:
$HOME/.google-docs-fs/access.cred

gmount %credfile% %mountpoint%

takes the credfile on another location

gmount %email% %mountpoint%

takes email, asks for a password on the commandline.

Looking to your comments,

Stef Bon

Original comment by Stef...@gmail.com on 4 May 2011 at 12:46

Attachments: