python-o365
python-o365 copied to clipboard
No auth token found. Authentication Flow needed
RuntimeError when attempting to send email via O365
I'm trying to send an email using the O365 Python package, but I'm encountering a RuntimeError stating that no auth token is found, and an Authentication Flow is needed. I have already authenticated my app with the Azur App Directory and obtained the necessary credentials. Here's the code I'm running:
from O365 import Account
CLIENT_ID = "YOUR_CLIENT_ID"
CLIENT_SECRET = "YOUR_CLIENT_SECRET"
Subject = 'Testing!'
TO = "[email protected]"
Body = "George Best quote: I've stopped drinking, but only while I'm asleep."
credentials = (CLIENT_ID, CLIENT_SECRET)
account = Account(credentials)
m = account.new_message()
m.to.add(TO)
m.subject = Subject
m.body = Body
m.send()
call account.authenticate
Or if you already have the token credentials, load the token into the token backend.