forked from mirror/django-mailbox
fix retrieving google oauth token
This commit is contained in:
parent
5a050b0ca3
commit
be66d04bf3
2 changed files with 7 additions and 1 deletions
|
|
@ -59,6 +59,10 @@ def google_api_get(email, url):
|
||||||
if r.status_code == 401:
|
if r.status_code == 401:
|
||||||
# Go use the refresh token
|
# Go use the refresh token
|
||||||
refresh_authorization(email)
|
refresh_authorization(email)
|
||||||
|
# Force use of the new token
|
||||||
|
headers = dict(
|
||||||
|
Authorization="Bearer %s" % get_google_access_token(email),
|
||||||
|
)
|
||||||
r = requests.get(url, headers=headers)
|
r = requests.get(url, headers=headers)
|
||||||
logger.info("I got a %s", r.status_code)
|
logger.info("I got a %s", r.status_code)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,10 @@ class GmailImapTransport(ImapTransport):
|
||||||
access_token = None
|
access_token = None
|
||||||
while access_token is None:
|
while access_token is None:
|
||||||
try:
|
try:
|
||||||
access_token = get_google_access_token(username)
|
# token refreshed here when expired
|
||||||
google_email_address = fetch_user_info(username)['email']
|
google_email_address = fetch_user_info(username)['email']
|
||||||
|
# retrieve token from db
|
||||||
|
access_token = get_google_access_token(username)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# This means that the google process took too long
|
# This means that the google process took too long
|
||||||
# Trying again is the right thing to do
|
# Trying again is the right thing to do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue