I’m a tad baffled as to why this bit of code has suddenly decided to fail when it had been working fine for a week.
import firebase_admin
from firebase_admin import firestore, credentials,db, auth
def userIsLoggedIn(self,id_token: str) -> bool:
try:
decoded_token = auth.verify_id_token(id_token)
self.uid = decoded_token['uid']
except Exception as e:
return False,str(e)
return True,""
The error message returned is:
‘HTTPResponse’ object has no attribute ‘strict’
And I can only replicate this error when I am testing on my cloud server as opposed to localhost.
I have reviewed the stack trace and I see it is the auth.verify_id_token
function causing issues, and specifically then:
ile "/usr/local/lib/python3.11/site-packages/cachecontrol/serialize.py", line 54, in dumps
2023-05-04T16:11:04.767062340Z u"strict": response.strict,
2023-05-04T16:11:04.767067540Z ^^^^^^^^^^^^^^^
2023-05-04T16:11:04.767072540Z AttributeError: 'HTTPResponse' object has no attribute 'strict'
EDIT:
Ok so Patrick below pointed me to a link that tells me:
"this appears to be an incompatibility in cachecontrol with the new release of urllib3 2.0. strict is no longer a supported argument on the HTTPResponse class. For the time being you’ll likely need to pin to an older version of urllib3 or work with the cachecontrol team to update their usage."
I’ll have to see if I can do anything about this for now. For example using urllib3 2.0.0 as a workaround as suggested by Patrick.
2
Answers
Looks like you’re hitting this bug:
https://github.com/ionrock/cachecontrol/issues/292
There is no fix posted so far.
Per the https://urllib3.readthedocs.io/en/stable/changelog.html#deprecated changelog, using 1.26.15 "fixed" this for me. [Edited: said to try using urllib3 2.0.0 as a workaround, but that did not work.]
I encountered the same error, likely due to the same underlying cause, when running
poetry install
. This won’t help OP, but in case anyone else finds this post for the same reason, I was able to get around it by upgrading from poetry 1.1.4 to 1.3.2.