Skip to content

Instantly share code, notes, and snippets.

@gscales
Created June 9, 2020 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gscales/2dadd866b6860c565754cce26ceaf2bb to your computer and use it in GitHub Desktop.
Save gscales/2dadd866b6860c565754cce26ceaf2bb to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp23
{
class OAuthExchangeServiceBinding : com.office365.outlook.ExchangeServiceBinding
{
public String AnchorMailbox { get; set; }
public bool oAuth;
public String oAuthToken;
protected override System.Net.WebResponse GetWebResponse(System.Net.WebRequest req)
{
if (AnchorMailbox != null)
{
if (AnchorMailbox != "")
{
req.Headers.Add("X-AnchorMailbox", AnchorMailbox);
}
}
if (oAuth)
{
req.Headers.Remove("Authorization");
req.Headers.Add("Authorization", "Bearer " + oAuthToken);
}
System.Net.HttpWebResponse
rep = (System.Net.HttpWebResponse)base.GetWebResponse(req);
return rep;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment