Using GRAPH API to send email with python.

만도 (박재성) 21 Reputation points

Hello. I'm building data pipeline and end of the pipeline is sending email using GRAPH API to colleagues in my company.

and I'm going to use python script, which will be running in a airflow pipeline.

So I'm going to write the script that will send post request (send email) from my local computer.

and I'm wondering what redirection URI should be used?

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
18,689 questions
0 comments No comments
{count} votes

Accepted answer
  1. Saurabh Sharma 23,251 Reputation points Microsoft Employee

    Hi @만도 (박재성) ,

    Thanks for using Microsoft Q&A !!

    As per my understanding of your scenario you need to call the Graph API to send the email (/me/microsoft.graph.sendMail) using the Application Identity ** instead of an user's identity. You can use MSAL for Python to achieve the same. You need to provide "Application Permissions" to Microsoft Graph while registering your application instead of using delegated permissions and required to provide an **Admin Consent to required permissions to make it work.

    Also, in your python code you need to pass account parameter as none like acquire_token_silent(config["scope"], account=None) as you are required to get token for the client and you do not need to provide the redirection URI. Please refer to this Microsoft documentation to for detailed steps and sample code. Please let me know if you have any other questions.


    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.

0 additional answers

Sort by: Most helpful