0
as i need to send email from microsoft o behalf of user who gave me mail sending permission below are the steps which i have followed
- created application in entra.microsoft.com
- added platform configuration as web and SPA
- Added permission for profile and mail for both application and delegated.
Now on code side followed below steps
- called below api from browser
https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize?client_id={client_id}&response_type=code&redirect_uri=http://localhost:3000&response_mode=query&scope=User.Read Mail.Read Mail.Send openid profile offline_access
- then getting code in query parameter
- used that code from step 5 in below API
https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token
where below is body in x-www-form-urlencoded format
client_id, scope=User.Read Mail.Read Mail.Send openid profile offline_access, code, redirect_uri, grant_type= authorization_code, client_secret.
in resopnse i am getting
token_type,scope,expires_in,ext_expires_in,access_token,refresh_token,id_token.
- Now i am using access_token from step 6 to send mail with below api
https://graph.microsoft.com/v1.0/users/" + fromEmailAddress + "/sendMail
but it always says
{ "error": { "code": "ErrorInvalidUser", "message": "The requested user is invalid." }
can someone help me to solve this issue
or suggest me proper way to perform this task
Thanks in advance
{ "error": { "code": "ErrorInvalidUser",
"message": "The requested user is invalid." }