Closed scop closed 8 years ago
I reverted this commit. git-bisect traced an HTTP 400 error in (at least) get_access_from_refresh() to this.
Could you provide more details? Everything I've tested -- including get_access_from_refresh() -- works fine for me with both Python 2.7.10 and 3.4.3 with these changes in on Fedora 23, no 400's observed.
It was from the url fetch in get_access_from_refresh(). I reinstalled, but didn't do anything to flush the keyring, so the refresh token should have been valid. I played with encoding, with no effect. Running the code from the commit before the Python 3 work succeeded.
I can try to reproduce, but I'm afraid it will be hard. Can you walk me through the exact steps starting from a completely clean setup (including how to clean up all existing tokens)?
If you still have the setup where this happens for you, perhaps you could just check if there's any difference in the urlencoded args POSTed before and after the change? And if there are no obvious changes, check differences in the actual requests with wireshark (that'll require changing token_endpoint to something non-https though, but just POSTing it somewhere unsecured where you don't mind sending that request's content would provide for the capture).
Also, with the original python 2 code you can get some debugging output of which the request contents are most interesting with:
import httplib
httplib.HTTPConnection.debuglevel = 1
And in the Python 3 (well, six) version:
from six.moves import http_client
http_client.HTTPConnection.debuglevel = 1
$ git checkout 06eb3373cc7996a408eb8933283ef4d7a512303a
Remove GNOME GMail connection from your GMail account.
$ ./gnomegmail.py mailto:joe@example.com?attach=/etc/resolv.conf
...
File "./gnomegmail.py", line 820, in
Ok, got it. The problem is that Google actually does send an HTTP 400 response to indicate that the token has been revoked, and whereas the old urllib passes it happily through, urllib2 doesn't but raises and error instead. #22 takes care of this.
Tested with 2.7.10 and 3.4.3 on Fedora 23, works with both as far as I can tell.
3.[0123] is not supported because POSTing data with urllib demands bytes and
msg.as_bytes()
exists only in 3.4+, and I don't have access to nor I care about earlier 3.x versions :)