I have a Web API backend with EF and use AzureAD to authenticate my (office365)users of the web application that is written in AngularJS.
Now I want to create a draft mail in my Web API but I don't know where to start.
Can I just call the Office 365 mail API in my Web API? POST https://outlook.office365.com/api/{version}/me/sendmail
But how do I pass the authentication token with it?
Here is the Auth config that I use now and it works for other data requests.
public static class Auth
{
internal static void ConfigureCors(this IAppBuilder app)
{
// TODO: Configure to only allow ESS Web UI
app.UseCors(CorsOptions.AllowAll);
}
internal static void ConfigureAuth(this IAppBuilder app)
{
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
TokenValidationParameters = new TokenValidationParameters
{
ValidAudience = Settings.Default.Audience
},
Tenant = Settings.Default.Tenant
});
}
}
Any one how has some sample code to make the correct request to the Office 365 API? Thank you! I'm new to the Office 365 API and this website: https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations
is not so clear for me to know how to handle this..