I have an application's clientId, tenantId, and secret from registering an app in Microsoft Azure services.
I managed to get a token, from here: https://login.microsoftonline.com/{tenantId} I also figured out that the scope should be this: https://graph.microsoft.com/.default
I tried to send an email with https://graph.microsoft.com/v1.0/me/sendMail endPoint, but I finally realized he /me is not good for me (I tried to replace the "me" with the email address that I want to send the email from, but that also not working).
Please give me help how should I use this API? I just want to send an email with OAuth2.
I registered one Azure AD application and granted
Mail.Sendpermission of Application type as below:Now, I generated access token using client credentials flow via Postman with below parameters:
Response:
You can decode the above token in jwt.ms and check whether it has roles claim with
Mail.Sendpermission:When I used this token to send mail with below API call via Postman, I got response like this:
Response:
To confirm that, I checked the same in user's
Sent Itemswhere mail sent successfully as below:In your case, "Access is denied. Check credentials and try again" error occurs if you granted
Mail.Sendpermission of Delegated type for client credentials flow.To resolve the error, make sure to grant
Mail.Sendpermission of Application type. Refer this SO thread that I previously answered.