Intermittent 401 Unauthorized errors
See original GitHub issueSometimes works, sometimes doesn’t. Restarting the app helps. Could this be because there is a long lag time between an authorization of a credential with gspread.authorize
and then taking actions on the session?
HTTPError: 401: <HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
Traceback (most recent call last):
File "/home/mark/timeobserver/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/mark/timeobserver/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/mark/timeobserver/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/mark/timeobserver/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/mark/timeobserver/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/mark/timeobserver/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/mark/timeobserver/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/mark/timeobserver/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/mark/timeobserver/server.py", line 42, in toggleWork
worksheet.append_row([session.timeStarted, datetime.datetime.now(), session.durationWorked, session.durationInterrupted, datetime.datetime.now() - session.timeStarted, session.interruptions])
File "/home/mark/timeobserver/lib/python2.7/site-packages/gspread/models.py", line 525, in append_row
self.add_rows(1)
File "/home/mark/timeobserver/lib/python2.7/site-packages/gspread/models.py", line 507, in add_rows
self.resize(rows=self.row_count + rows)
File "/home/mark/timeobserver/lib/python2.7/site-packages/gspread/models.py", line 488, in resize
feed = self.client.get_feed(self_uri)
File "/home/mark/timeobserver/lib/python2.7/site-packages/gspread/client.py", line 256, in get_feed
r = self.session.get(url)
File "/home/mark/timeobserver/lib/python2.7/site-packages/gspread/httpsession.py", line 75, in get
return self.request('GET', url, **kwargs)
File "/home/mark/timeobserver/lib/python2.7/site-packages/gspread/httpsession.py", line 71, in request
response.status_code, response.content))
gspread latest (0.3.0)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:31 (3 by maintainers)
Top Results From Across the Web
Very intermittent 401 error - MSDN - Microsoft
Very occasionally, across our web farm, on various sites, I get this error returned to the browser: "401 - Unauthorized: Access is denied...
Read more >Intermittent '401: Unauthorized' exceptions from server
The service is a WCF Service but has been created to be compatible with the .Net 2.0 Web Service framework. The application runs...
Read more >Getting intermittent 401 Errors with BasicAuthentication policy
1. Looked at the trace and found that the cause for the 401 error was that the Authorization header was missing as part...
Read more >401 Error: 5 Ways to Troubleshoot and Fix It - Hostinger
The 401 Unauthorized error is triggered by unauthenticated requests made to a WordPress web server. Learn how to identify and fix the issue....
Read more >Intermittent 401 Unauthorized Error When Accessing Fusion ...
Customer create a program to invoke fusion application rest API, sometime it works, sometime it will get 401 Unauthorized error. When the error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kotborealis thanks for your fix, I’ve updated my comment too
I have tested the snippet and here is the final solution, that works for me (proxy class for worksheet):