I have a python script to send message using msgraph, but I can’t do it I have authorization issue, but when I get token directly on msgraph site I can do it, but I try to get the token using my python script the token don’t have permission to send message.
For this, I can see that I have some privileges permission, I register a APP and gave a lot of permissionst (30) including teammigration.
could you send me all privileges I can attribute to my app registered?
As I told, when I change the token and use a msgraph site token my code send message, when I try to get the token using code, the token received don’t have permissions to send message.
This code get a token, but this token don’t have permisssion to send message and I have the error:
401
{“error”:{“code”:”Unauthorized”,”message”:”Message POST is allowed in application-only context only for import purposes.
but using the same code, but using a token that I get on msgraph site and using this token, I can send message normally.
example code to get token:
# Set up the MSAL confidential client
authority = f”https://login.microsoftonline.com/{tenant_id}”
scope = [“https://graph.microsoft.com/.default”]
app = msal.ConfidentialClientApplication(
client_id,
authority=authority,
client_credential=client_secret
)
# Acquire a token
result = app.acquire_token_for_client(scopes=scope)
if “access_token” in result:
access_token = result[“access_token”]
Haysar Lelis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.