django-mailbox icon indicating copy to clipboard operation
django-mailbox copied to clipboard

`google_api_get()` function does not refresh headers and does same request twice with 401 error.

Open xelblch opened this issue 9 years ago • 3 comments

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?

xelblch avatar Feb 29 '16 18:02 xelblch

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!

coddingtonbear avatar Feb 29 '16 18:02 coddingtonbear

+1

afedosenko avatar Jul 06 '16 16:07 afedosenko

@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.

coddingtonbear avatar Jul 06 '16 16:07 coddingtonbear