Gspread stuck on authorization
Question:
So I’m running this code from the tutorial but can’t even get through the authorization process.
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('path/to/oauth.json', scope)
gc = gspread.authorize(credentials)
table = gc.openall()
After n minutes of waiting when I interrupt the process, I see that it hangs on
File "/usr/lib/python3.5/http/client.py", line 1252, in connect
super().connect()
File "/usr/lib/python3.5/http/client.py", line 849, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/lib/python3.5/socket.py", line 702, in create_connection
sock.connect(sa)
KeyboardInterrupt
executing this method gspread.authorize(credentials)
.
Do you have any idea what could be the problem? I tried with multiple oauth jsons so I guess it’s not a problem on Google’s side.
I tried reading the json and passing args on my own with the same result.
I created json files from two different Google accounts, one of which is in the company domain, with the same result.
I’m running the code on Ubuntu 16.04, PyCharm 2017.2.4, with Python 3.5 and gspread 0.6.2.
Edit: The exact same problem occurs on Jupyter Notebook.
Answers:
Ok, it works, but I literally had to wait over 10 minutes. People running the exact same code on youtube see the output immediately. Still, if you have any idea what’s the cause of this delay or how to debug this socket problem, please let me know.
maybe I can find resolution.
I have a connection to the Wireguard VPN, after down connection, api works perfect
PS
Sorry for my so bad english
I was following the documentation to access sheet through python and it hanged at the OAuth token generation…
Visiting the auth link in a private window
solved it.
Either a socket was hanging or switching from spreadsheet.readonly to full read-write spreadsheet caused some caching cookie issue.
So I’m running this code from the tutorial but can’t even get through the authorization process.
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('path/to/oauth.json', scope)
gc = gspread.authorize(credentials)
table = gc.openall()
After n minutes of waiting when I interrupt the process, I see that it hangs on
File "/usr/lib/python3.5/http/client.py", line 1252, in connect
super().connect()
File "/usr/lib/python3.5/http/client.py", line 849, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/lib/python3.5/socket.py", line 702, in create_connection
sock.connect(sa)
KeyboardInterrupt
executing this method gspread.authorize(credentials)
.
Do you have any idea what could be the problem? I tried with multiple oauth jsons so I guess it’s not a problem on Google’s side.
I tried reading the json and passing args on my own with the same result.
I created json files from two different Google accounts, one of which is in the company domain, with the same result.
I’m running the code on Ubuntu 16.04, PyCharm 2017.2.4, with Python 3.5 and gspread 0.6.2.
Edit: The exact same problem occurs on Jupyter Notebook.
Ok, it works, but I literally had to wait over 10 minutes. People running the exact same code on youtube see the output immediately. Still, if you have any idea what’s the cause of this delay or how to debug this socket problem, please let me know.
maybe I can find resolution.
I have a connection to the Wireguard VPN, after down connection, api works perfect
PS
Sorry for my so bad english
I was following the documentation to access sheet through python and it hanged at the OAuth token generation…
Visiting the auth link in a private window
solved it.
Either a socket was hanging or switching from spreadsheet.readonly to full read-write spreadsheet caused some caching cookie issue.