gspread icon indicating copy to clipboard operation
gspread copied to clipboard

Oauth2 Authorization fails to work

Open mosesmc52 opened this issue 11 years ago • 11 comments

I followed the instructions on this page ( http://gspread.readthedocs.org/en/latest/oauth2.html).

Inserted the following lines to connect to Oauth json_key = json.load(open('gspread-april-2cd … ba4.json')) scope = ['https://spreadsheets.google.com/feeds']

credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope) gc = gspread.authorize(credentials)

But the output was the following traceback error..... How could I fix this problem.

traceback (most recent call last): File "code/upload_form6.py", line 625, in instance.upload() File "code/upload_form6.py", line 514, in upload gc = gspread.authorize(credentials) File "/Users/mosesmccall/.virtualenvs/form6/lib/python2.7/site-packages/gspread/client.py", line 335, in authorize client.login() File "/Users/mosesmccall/.virtualenvs/form6/lib/python2.7/site-packages/gspread/client.py", line 98, in login self.auth.refresh(http) File "/Users/mosesmccall/.virtualenvs/form6/lib/python2.7/site-packages/oauth2client/client.py", line 577, in refresh self._refresh(http.request) File "/Users/mosesmccall/.virtualenvs/form6/lib/python2.7/site-packages/oauth2client/client.py", line 748, in _refresh self._do_refresh_request(http_request) File "/Users/mosesmccall/.virtualenvs/form6/lib/python2.7/site-packages/oauth2client/client.py", line 772, in _do_refresh_request body = self._generate_refresh_request_body() File "/Users/mosesmccall/.virtualenvs/form6/lib/python2.7/site-packages/oauth2client/client.py", line 1379, in _generate_refresh_request_body assertion = self._generate_assertion() File "/Users/mosesmccall/.virtualenvs/form6/lib/python2.7/site-packages/oauth2client/client.py", line 1508, in _generate_assertion private_key, self.private_key_password), payload) File "/Users/mosesmccall/.virtualenvs/form6/lib/python2.7/site-packages/oauth2client/crypt.py", line 134, in from_string pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, parsed_pem_key) File "/Users/mosesmccall/.virtualenvs/form6/lib/python2.7/site-packages/OpenSSL/crypto.py", line 2323, in load_privatekey _raise_current_error() File "/Users/mosesmccall/.virtualenvs/form6/lib/python2.7/site-packages/OpenSSL/_util.py", line 48, in exception_from_error_queue raise exception_type(errors) OpenSSL.crypto.Error: []

mosesmc52 avatar Apr 24 '15 21:04 mosesmc52

@mosesmc52 check solution in #224

elliotslab avatar Apr 27 '15 14:04 elliotslab

Using the solution in ticket #224, is there any alternative approach to submitting the Google credentials other than submitting through an environmental variable?

mosesmc52 avatar Apr 27 '15 20:04 mosesmc52

I would also like that - and the docs need updating!

felagund avatar May 05 '15 10:05 felagund

@felagund this project is open for any kind of contributions :)

burnash avatar May 05 '15 11:05 burnash

Yes, but I doubt the solution with enviromnet variable is a correct one, so I do not know how I could update the docs.

felagund avatar May 05 '15 11:05 felagund

I mean, I consider that solution just a workaround and that whóle byte<>unicode python2/3 thing puzzles me too much to come up with a proper solution myself. Moreover, I have not even tried the workaround, I am kind of waiting for a "proper fix" to update my code, I expect the deprecated api to work for some time (my code still works).

felagund avatar May 05 '15 15:05 felagund

@felagund I also don't like the solution with env vars. But at the moment I don't have any alternatives. Does your working code use ClientLogin?

burnash avatar May 05 '15 20:05 burnash

@felagund I also don't like the solution with env vars. But at the
moment I don't have any alternatives. Your working code uses ClientLogin?

No, I just use gspread.login() using my password and e-mail in plaintext
in the source code, it still works.

felagund avatar May 05 '15 22:05 felagund

@felagund, have you solved your issue?

msuozzo avatar Oct 11 '15 20:10 msuozzo

Yeah, I did. I don't know about hte OP.

felagund avatar Oct 11 '15 22:10 felagund

Cool. I'll close the issue and if it crops up again, OP can reopen it.

Thanks.

msuozzo avatar Oct 11 '15 22:10 msuozzo