Head over to the Microsoft Graph documentation page to get more information about the Mail, Calendar, and Contacts APIs, including guidance for setting up your environment and getting started with the APIs.Īlso be sure to check out the quick starts and code samples to see these APIs in action. You can use the Contacts API to get, create, update, and delete contacts in a user's mailbox. You can also get, create, update, and delete calendar groups and calendars. You can use the Calendar API to get, create, update, and delete events. Work with events, calendars, and calendar groups You can also get, create, update, and delete mail folders. You can use the Mail API to get, create, update, delete, move, copy, and send email. For example, you might design your application to request permission and read only a user's calendar. OAuth makes it possible to request tightly scoped permissions to user data. This provides the following advantages:īecause these APIs require OAuth for authentication, your application does not have to handle or store user credentials. These APIs are based on open standards: OAuth version 2.0 for authentication, and OData version 4.0 and JSON for data abstraction.
The SubscribeToPushNotifications(IEnumerableThe Microsoft Graph Mail, Calendar, and Contact REST APIs provide a powerful, easy-to-use way to access and manipulate Exchange data. Initiates a request for a client to receive push notifications. Office 365, Exchange Online, and Exchange Server in hybrid deployments provide a new way to work with email, calendars, and contacts. Find information about the Microsoft Graph APIs that you can use to access mail, calendars, and contacts in Office 365, Exchange Online, or Exchange Server in hybrid deployments. Split ( ' / ' ) $app = :: Create ( $ClientId ). Split ( ' / ' ) $pcaConfig = :: Create ( $ClientId ). Add ( $Scope ) $TenantId = ( Invoke-WebRequest | ConvertFrom-Json ).
Some simple auth examples for this would be If your using PowerShell you can use the same code as above as long as import the MSAL library dll into your session
Because tokens are only valid for 1 hour if you have a long running process like a migration/export or data analysis then you need to make sure that you have some provision in your code to track the expiry of the access token and the refresh the token when needed. One of the big things missing in the EWS Managed API is a callback before each request that checks for an expired Access Token. Bind (service, new FolderId (WellKnownFolderName. SmtpAddress, mailboxName ) įolder Inbox = Folder. ImpersonatedUserId = new ImpersonatedUserId (ConnectingIdType. Add ( " X-AnchorMailbox ", mailboxName )
Credentials = new OAuthCredentials (TokenResult. Result ĮxchangeService service = new ExchangeService (ExchangeVersion.
WithRedirectUri (redirectUri ) var TokenResult = pcaConfig. PublicClientApplicationBuilder pcaConfig = PublicClientApplicationBuilder. GetAsync ( " " + domainName + " /v2.0/.well-known/openid-configuration " ). HttpClient Client = new HttpClient ( ) var TenantId = ( (dynamic )JsonConvert. String MailboxName = " " string scope = " " string redirectUri = " msal9d5d77a6-fe09-473e-8931-958f15f1a96b://auth " string domainName = " " This is the simplest C# example of an Auth using the MSAL library in a Console app to logon (the currently logged on user). If its a shared Mailbox then access will need to be have granted via Add-MailboxFolderPermission or you using EWS Impersonation This is the simplest C example of an Auth using the MSAL library in a Console app to logon. If its a shared Mailbox then access will need to be have granted via Add-MailboxFolderPermission or you using EWS Impersonation. This generally is the most common way of using EWS where your authenticating as a standard User and then accessing a Mailbox. This generally is the most common way of using EWS where your authenticating as a standard User and then accessing a Mailbox. $TenantId = (Invoke-WebRequest | ConvertFrom-Json).token_endpoint.Split('/')ĭelegate Authentication in EWS with MSAL and the EWS Managed API