`google_api_get()` function does not refresh headers and does same request twice with 401 error.
Hi there,
I'm trying to use django-mailbox library on one of my projects together with python-social-auth. The problem I found related to google_api_get() function here:
https://github.com/coddingtonbear/django-mailbox/blob/master/django_mailbox/google_utils.py#L53
Your first request on the line 57 in case of expired token will return 401 status code. So after this, you trying to refresh access token and store it in the database by calling refresh_authorization() function on line 61.
But after token refreshed and stored back to database you doing the same GET request on line 62. You still using old headers with old access token. This request also return 401 status code and there's None returned from this function.
Looks like you missed to update headers before doing this second GET request?
Hey there @xelblch, could you post a pull request fixing that? I'm not directly aware of how the gmail interactions work given that they were contributed by a patch, so I'll trust you if you think there's an oversight.
Cheers!
+1
@afedosenko -- if you, too, are interested in such a fix, could you contribute a patch adding this feature? I don't foresee having the time in the near future.