Skip to content

Commit 0722227

Browse files
authored
SCOPES must be the same to refresh
1 parent c33afea commit 0722227

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

general/gmail-api/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def gmail_authenticate():
1919
creds = pickle.load(token)
2020
# if there are no (valid) credentials availablle, let the user log in.
2121
if not creds or not creds.valid:
22-
if creds and creds.expired and creds.refresh_token:
22+
if creds and creds.expired and creds.refresh_token and SCOPES == creds._scopes::
2323
creds.refresh(Request())
2424
else:
2525
flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)
@@ -40,4 +40,4 @@ def search_messages(service, query):
4040
result = service.users().messages().list(userId='me',q=query, pageToken=page_token).execute()
4141
if 'messages' in result:
4242
messages.extend(result['messages'])
43-
return messages
43+
return messages

0 commit comments

Comments
 (0)