@MishraDolly-9847, Thank you for sharing the details. Lets understand the auth process a bit that would be used in this case. To call the AAD protected APIs like Microsoft Graph API, you would need an access token issued by AAD for Graph API to consume before you can use the API to fetch the required information or perform a specific task. To get the access-token from AAD, you can flow either of the two ways:
Authorization-Code Grant Flow: This flow is usually used to get a user signed in using a browser and after successful authentication, AAD would issue an access-token in user's context. This flow needs an Interactive Login process, i.e entering the username and password manually when prompted for by AAD.
Client-Credential Flow: This flow is used, when an application would need to fetch an access-token from AAD. This flow issues an access-token in application's context after authenticating the application registered in AAD. This flow is a non-interactive flow but only works in case of applications.
Now, for you can since you are using the /events graph API, you would need to use the Authorization-Code Grant flow to fetch a token from AAD, as this API would work only when the token issue to the user who just authenticated itself with AAD and provides the token that AAD issued to him/her.
As per your query "but in the meeting, request sender will be a different person which I should be able to pass while calling API", you can do that by following the steps mentioned below:
First of all the other person on whose behalf you would be sending the invite, he/she should get his calendar shared with you. You can check the following article to get the understanding on how to do that: https://www.microsoft.com/en-us/microsoft-365/blog/2013/09/04/configuring-delegate-access-in-outlook-web-app/
Once the calendar is shared with you, now perform the steps to get an access-token from AAD on for yourself and then call the following Graph API: GET https://graph.microsoft.com/v1.0/me/calendars
From the output of the previous Graph API call, you can fetch the calendar Id of the shared calendar and then next you can call the second graph api to send the invitation:
POST https://graph.microsoft.com/v1.0/me/calendars/AAMkADRpAABf0JlzAAA=/events
Prefer: outlook.timezone="Pacific Standard Time"
Content-type: application/json
"subject": "Christmas dinner",
"body": {
"contentType": "HTML",
"content": "Happy holidays!"
},
"start": {
"dateTime": "2019-12-25T18:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2019-12-25T22:00:00",
"timeZone": "Pacific Standard Time"
},
"location":{
"displayName":"Alex' home"
},
"attendees": [
{
"emailAddress": {
"address":"meganb@contoso.onmicrosoft.com",
"name": "Megan Bowen"
},
"type": "required"
},
{
"emailAddress": {
"address":"ChristieC@contoso.onmicrosoft.com",
"name": "Christie Cline"
},
"type": "required"
}
]
}
More details can be found here: https://learn.microsoft.com/en-us/graph/outlook-create-event-in-shared-delegated-calendar?tabs=http
Once the invitation is sent, you would find the organizer as the other person, on whose behalf you have sent the email. In my case, I have used two users dummyuser1 and dummyuser2. Dummyuser1 has shared his calendar with dummyuser2 and then dummyuser2 uses the shared calendar to send the invite.
Hope this helps.
Do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. Also, please do not forget to accept the response as Answer; if the above response helped in answering your query.