1

I have a web application which uses the django framework. I am using gspread to parse some data from googlesheet. On my local machine the script is running well, but once it is deployed on the web server, after about one hour I get this error:


    File "/home/ZhukovGreen/rmkPrjWeb/myvenv/local/lib/python2.7/site-packages/gspread/httpsession.py", line 72, in request
        response.status_code, response.content))
    HTTPError: 401: 
    
    Token invalid - Invalid token: Stateless token expired
    
    
    

Token invalid - Invalid token: Stateless token expired

Error 401

Thank you.

zhukovgreen
  • 1,551
  • 16
  • 26
  • How do you authenticate gspread on your local machine and on the server? – Burnash Oct 22 '16 at 21:40
  • @Burnash I am using service account and generated json file (the same for my local machine and the web server) – zhukovgreen Oct 23 '16 at 06:16
  • Do your local tests run for longer than 1 hour without error? If not, then it might be due to this error for which I gave an answer http://stackoverflow.com/questions/38880188/gspread-w-oauth2client-service-account-key – roganjosh Oct 24 '16 at 10:41
  • 1
    @roganjosh thanks. It was the issue. Now it works – zhukovgreen Oct 24 '16 at 17:32
  • Glad it helped you :) I'm going to flag as duplicate because `gspread` seems to have similar issues with authorisation cropping up again and again, which are somewhat hard to track down because they're unexpected. A dupe tag will make the re-direct to an answer more obvious. – roganjosh Oct 24 '16 at 18:52

0 Answers0