('invalid_scope: Bad Request', {'error': 'invalid_scope', 'error_description': 'Bad Request'})
Области моего кода включают:
Код: Выделить всё
SCOPES = [
'https://www.googleapis.com/auth/gmail.readonly',
'https://www.googleapis.com/auth/gmail.send',
'https://www.googleapis.com/auth/contacts.readonly',
'https://www.googleapis.com/auth/contacts',
'https://www.googleapis.com/auth/userinfo.email',
'openid'
]
Код: Выделить всё
def send_email(self, userToEmail, messageText):
try:
service = build('gmail', 'v1', credentials=self.load_credentials())
message = MIMEText(messageText)
message['to'] = userToEmail
message['subject'] = 'Test Email'
encoded_message = base64.urlsafe_b64encode(message.as_bytes()).decode()
result = service.users().messages().send(userId="me", body={'raw': encoded_message}).execute()
return f"Message sent: {result['id']}"
except Exception as error:
print("Error:", error)
return f"Error occurred: {error}"
Подробнее здесь: https://stackoverflow.com/questions/791 ... -in-python