Unable to connect to shared enterprise mailbox with python

TiagoFerreira123 0 Reputation points
2025-03-11T15:29:03.86+00:00

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

Microsoft 365 and Office | Development | Other
{count} votes

1 answer

Sort by: Most helpful
  1. TiagoFerreira123 0 Reputation points
    2025-03-19T16:01:03.5333333+00:00

    I'm waiting for a response if you could please help me that would be great, thank you. @Microsoft office development team

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.