python-o365 icon indicating copy to clipboard operation
python-o365 copied to clipboard

No auth token found. Authentication Flow needed

Open akesh1235 opened this issue 1 year ago • 1 comments

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()

akesh1235 avatar Mar 11 '24 08:03 akesh1235

call account.authenticate

Or if you already have the token credentials, load the token into the token backend.

alejcas avatar Mar 11 '24 08:03 alejcas