opengridcc / opengrid-dev

Open source building monitoring, analysis and control
Apache License 2.0
26 stars 21 forks source link

Depreciation gspread #51

Closed JrtPec closed 9 years ago

JrtPec commented 9 years ago

I stumbled on this warning while using gspread to fetch metadata from a google spreadsheet (it doesn't show in iPython, but does in the terminal):

/usr/local/lib/python2.7/dist-packages/gspread/client.py:73: Warning: 
        ClientLogin is deprecated:
        https://developers.google.com/identity/protocols/AuthForInstalledApps?csw=1

        Authorization with email and password will stop working on April 20, 2015.

        Please use oAuth2 authorization instead:
        http://gspread.readthedocs.org/en/latest/oauth2.html

Today was april 24, and it still works, but for how long...?

Does anybody have experience with oAuth2 and gspread?

wouterh commented 9 years ago

As far as I know, there is no email and password in the config but a key that looks like an oauth token. Maybe we already use oauth? @saroele probably knows?

JrtPec commented 9 years ago

I'm talking about this piece of code from houseprint.py:

    pwdfile = file(os.path.join(self.sourcedir, 'og.txt'))
    pwd = pwdfile.readlines()[0].rstrip()

    # open spreadsheet, store main sheet in self.sheet
    self.gc = gspread.login('opengridcc@gmail.com', pwd)

Looks like an email and password to me. Try it in a terminal and you will get the warning.

saroele commented 9 years ago

Yes, we use password login through gspread. Honestly, I have no idea how to set up oauth identification. On the other hand, we may use this occasion to discuss the relevance of the houseprint spreadsheet and consider switching to a different format?

On the short term, oauth authorisation looks like the best solution if we can quickly fix this. So I have to repeat Jan's question: anyone experience with this?

JrtPec commented 9 years ago

I'm on it. I have already tested it with a personal project of mine and am now implementing it for Open Grid. Expect a working branch in a matter of minutes ;-)

The authorization makes use of json file with keys and such, so we will have to e-mail that around or something.

JrtPec commented 9 years ago

https://github.com/JrtPec/opengrid/tree/issue_51OAuth2-GSpread

There it is. I have followed the instructions from http://gspread.readthedocs.org/en/latest/oauth2.html so I've needed to enable the Google Drive API for opengridcc@gmail.com, create a credential json and share the houseprint sheet with it.

@saroele I'll e-mail you the json file so you can pass it on to the other devs

saroele commented 9 years ago

Great, I can test it tomorrow and I'll mail the json to all devs. Op 25 apr. 2015 12:42 schreef "Jan Pecinovsky" notifications@github.com:

https://github.com/JrtPec/opengrid/tree/issue_51OAuth2-GSpread

There it is. I have followed the instructions from http://gspread.readthedocs.org/en/latest/oauth2.html so I've needed to enable the Google Drive API for opengridcc@gmail.com, create a credential json and share the houseprint sheet with it.

@saroele https://github.com/saroele I'll e-mail you the json file so you can pass it on to the other devs

— Reply to this email directly or view it on GitHub https://github.com/opengridcc/opengrid/issues/51#issuecomment-96175425.

saroele commented 9 years ago

Jan,

Seems like a neat implementation, cool! I still have to test, but i first need your branch.

The easiest solution is if you make a pull request to the develop branch of opengridcc/opengrid. I can of course add your fork to my remotes but a pull request is more gitty.