I coded a simple python script to get the inbox of an user in my company's tenant. The licence in this specific user is an Office F3. Here is my code:
import O365
from O365 import Account, Connection, MSGraphProtocol, Message
scopes=['basic', 'message_all']
credentials=('user@domain', 'password')
account = Account(credentials = credentials)
if not account.is_authenticated: # will check if there is a token and has not expired
account.authenticate(scopes=scopes)
account.connection.refresh_token()
mailbox = account.mailbox()
inbox = mailbox.get_folder(folder_name='Inbox')
child_folders = inbox.get_folders(25)
for folder in child_folders:
print(folder.name, folder.parent_id)
for message in inbox.get_messages(5):
if message.subject == 'test':
print(message.body)
When I run it it tells me to copy and paste an url and when i click on it i get the following error:
CMD prompt when I run the code
AADSTS700016: Application with identifier 'x' was not found in the directory 'y'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.
Anyone knows how to fix it?