Unable to connect to shared enterprise mailbox with python
I'm trying to read and write in a shared mailbox using python code.
I'm getting this error after running the code, it opens a page with the error:
AADSTS65002: Consent between first party application xxx and first party resource xxx must be configured via preauthorization - applications owned and operated by Microsoft must get approval from the API owner before requesting tokens for that API.
This is the code that I am trying to run:
from msal import PublicClientApplication
CLIENT_ID = "d3xxxx1c" # Microsoft default public client ID
TENANT_ID = "e0xxxxeb"
SCOPES = ["User.Read"]
app = PublicClientApplication(CLIENT_ID, authority=f"https://login.microsoftonline.com/{TENANT_ID}")
token_result = app.acquire_token_interactive(SCOPES)
print(token_result) # This should return an access token