<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Omar Venado&amp;#39;s Blog</title><subtitle type="html" /><id>http://blogs.msdn.com/b/omarv/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/omarv/" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/b/omarv/atom.aspx" /><generator uri="http://telligent.com" version="5.6.50428.7875">Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><updated>2012-10-25T19:57:00Z</updated><entry><title>Developing Windows 8 Store Apps for SharePoint Online with SSO (Single Sign On)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/omarv/archive/2012/11/15/developing-windows-store-apps-for-sharepoint-online-with-sso-single-sign-on.aspx" /><id>http://blogs.msdn.com/b/omarv/archive/2012/11/15/developing-windows-store-apps-for-sharepoint-online-with-sso-single-sign-on.aspx</id><published>2012-11-15T10:25:00Z</published><updated>2012-11-15T10:25:00Z</updated><content type="html">&lt;div class="WordSection1"&gt;
&lt;p class="MsoNormal"&gt;A few folks have asked me if I could tweak the code&amp;nbsp;from my &lt;a href="http://blogs.msdn.com/b/omarv/archive/2012/10/25/windows-8-store-apps-office-365-enterprise-preview-sharepoint-online.aspx"&gt;previous post&lt;/a&gt; to enable SSO into SharePoint Online from&amp;nbsp;a Windows Store App so here I am again with Parte Dos. This basically means users can use their corporate credentials or, even better, Windows integrated authentication (if they are connected to their corporate network) to access SPO content right from the Windows Store App. Office 365 has full support for SSO via ADFS (Active Directory Federation Services).&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;There are many advantages to SSO but the most important (always thinking about the customer) in my opinion are:&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l6 level1 lfo1;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;1)&lt;span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;1) Users don&amp;rsquo;t have to remember and enter multiple pairs of credentials to sign into different services/applications&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l6 level1 lfo1;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;2)&lt;span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;2) User&amp;rsquo;s don&amp;rsquo;t&amp;rsquo; have to manage multiple credentials such as periodically updating passwords for security reasons&lt;/p&gt;
&lt;p class="MsoNormal"&gt;When you sign up for an O365 tenancy you can configure it for SSO as described &lt;a href="http://onlinehelp.microsoft.com/en-us/office365-enterprises/hh125004.aspx"&gt;here&lt;/a&gt;. If you are interested in a quick overview of how SSO works in O365 &lt;a href="http://community.office365.com/en-us/wikis/sso/727.aspx"&gt;this&lt;/a&gt; is a good place to start. I also recommend looking over this excellent &lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=28971"&gt;whitepaper&lt;/a&gt; that explains in detail SSO configuration as well as the mechanics behind the core SSO scenarios. This post assumes an SSO has been configured as outlined in the links above and an ADFS proxy has been deployed to allow users to connect from outside their corporate network.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;Now before we proceed you should know the code referenced in this post was written solely for illustration purposes (it is by NO means production quality). Also, it is provided as is without warranty of any kind either expressed or implied. Ok, now that you have been warned let&amp;rsquo;s dive in.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;I modified the code in the previous post so the Windows Store App can now authenticate the user in 3 different ways:&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l5 level1 lfo2;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;1)&lt;span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;1) Using integrated Windows authentication if the user is connected to the corporate network&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l5 level1 lfo2;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;2)&lt;span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;2) Using the user&amp;rsquo;s corporate credentials if the user is outside of the corporate network&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l5 level1 lfo2;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;3)&lt;span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;3) Using the user&amp;rsquo;s O365 credentials (from the previous post)&lt;/p&gt;
&lt;p class="MsoNormal"&gt;For 1 and 2 above this post assumes SSO has been configured properly so O365 can recognize the user as being part of a federated domain. Needless to say, all communications must happen over SSL for security reasons. Next we will walk through the code changes for 1 and 2. Most code changes are in &lt;span class="SpellE"&gt;SpoAuthUtility.cs&lt;/span&gt;. Now for those of you that know all this stuff already and can&amp;rsquo;t wait to get your hands dirty you can scroll down to the end of the post and download the sample code.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;1.&lt;span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;SSO via Integrated Windows Authentication&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/1488.loginScreen.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/1488.loginScreen.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/6201.sso_5F00_integratedwinauth.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/6201.sso_5F00_integratedwinauth.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;The diagram above shows at high level how the App achieves SSO using integrated Windows Authentication.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;The first thing the App does is to ask the user for his UPN (User Principal Name). This is normally in the form of &lt;a href="mailto:user1@contoso.com"&gt;user1@contoso.com&lt;/a&gt;.&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;The Windows Store App presents the UPN to the HRD (Home Realm Discovery) service to resolve the &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;url&lt;/span&gt;&lt;/span&gt; of the corporate ADFS proxy to use for authentication. This step is not necessary if your app already knows the address of your corporate ADFS.&lt;/p&gt;
&lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l4 level1 lfo6;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l4 level1 lfo6;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormalCxSpFirst" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;const &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;msoHrdUrl&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"https://login.microsoftonline.com/&lt;span class="SpellE"&gt;GetUserRealm.srf&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;private &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;async &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Task&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt; &lt;span class="SpellE"&gt;GetAdfsAuthUrl&lt;/span&gt;()&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// make a post request with the user's login name to &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 1in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// MSO HRD (Home Realm Discovery) service so it can find &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 1in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// out the &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;url&lt;/span&gt;&lt;/span&gt; of the federation service (corporate ADFS) &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 1in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// responsible for authenticating the user&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;byte&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;] response = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.SendHttpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;span class="SpellE"&gt;msoHrdUrl&lt;/span&gt;),&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Post&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;MemoryStream&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Encoding&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.UTF8.GetBytes(&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;String&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Format(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"handler=1&amp;amp;login={0}"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.username&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;))), &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// pass in the login name in the body of the form&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="GramE"&gt;application/x-www-form-&lt;span class="SpellE"&gt;urlencoded&lt;/span&gt;&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;StreamReader&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;sr&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;StreamReader&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;MemoryStream&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(response));&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Dictionary&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;String&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;IJsonValue&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt; &lt;span class="SpellE"&gt;dict&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Dictionary&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;IJsonValue&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.ParseJson(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;JsonObject&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Parse(&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Encoding&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.UTF8.GetString(response, 0, &lt;span class="SpellE"&gt;response.Length&lt;/span&gt;)), &lt;span class="SpellE"&gt;dict&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// the corporate STS &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;url&lt;/span&gt;&lt;/span&gt; is in the &lt;span class="SpellE"&gt;AuthURL&lt;/span&gt; element of the response body&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;corpAdfsProxyUrl&lt;/span&gt; = &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;dict.ContainsKey&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="SpellE"&gt;AuthURL&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;) ? &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;span class="SpellE"&gt;dict&lt;/span&gt;[&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="SpellE"&gt;AuthURL&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;].&lt;span class="SpellE"&gt;GetString&lt;/span&gt;()) : &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;corpAdfsProxyUrl&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpLast" style="line-height: normal; margin-left: 0.25in; mso-add-space: auto;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l4 level1 lfo6;"&gt;&lt;span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;"&gt;&lt;span style="mso-list: Ignore;"&gt;&amp;middot;&lt;span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;The App then sends a security token request via HTTP GET to the corporate ADFS integrate authentication endpoint specifying 2 main things: the username and the realm which in this case is the O365 federation service. The &lt;span class="SpellE"&gt;url&lt;/span&gt; looks something like the following:&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="https://{contosoADFSUrl}/adfs/ls/auth/integrated/?cbcxt=&amp;amp;vv=&amp;amp;username=user@contoso.com&amp;amp;mkt=&amp;amp;lc=&amp;amp;wa=wsignin1.0&amp;amp;wtrealm=urnfederationMicrosoftOnline"&gt;https://{contosoADFSUrl}/adfs/ls/auth/integrated/?cbcxt=&amp;amp;vv=&amp;amp;username=user@contoso.com&amp;amp;mkt=&amp;amp;lc=&amp;amp;wa=wsignin1.0&amp;amp;wtrealm=urn:federation:MicrosoftOnline&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;If the user is connected to the corporate network the service request will automatically get authenticated by the magic of Kerberos and we will get a signed SAML token back in the body of the response that asserts who the user is. The token will be in the form of a SAML assertion (refer to the WS-Trust standard for more details). This is our logon token.&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpClientHandler&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; handler = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpClientHandler&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="SpellE"&gt;handler.UseDefaultCredentials&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;true&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;; &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// use the default credentials so Kerberos can take care of authenticating our request&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;byte&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;] &lt;span class="SpellE"&gt;stsresponse&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.SendHttpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.adfsIntegratedAuthUrl&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="GramE"&gt;text/html&lt;/span&gt;; charset=utf-8"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="GramE"&gt;handler&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// the security token response we got from ADFS is in the &lt;span class="SpellE"&gt;wresult&lt;/span&gt; input element&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;wresult&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;from&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;in&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;form.FirstOrDefault&lt;/span&gt;().Descendants()&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;e.Name&lt;/span&gt; == &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XName&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"input"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;) &amp;amp;&amp;amp;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;e.Attribute&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XName&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"name"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;)) != &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &amp;amp;&amp;amp;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;e.Attribute&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XName&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"name"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;)).Value == &lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="SpellE"&gt;wresult&lt;/span&gt;"&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="color: black; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// the logon token is in the SAML assertion element&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XDocument&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; xDoc1 = &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XDocument&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Parse(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;wresult.FirstOrDefault().Attribute(&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XName&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"value"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;)).Value, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;LoadOptions&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.PreserveWhitespace&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; assertion = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;from&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;in&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; xDoc1.Descendants()&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;e.Name&lt;/span&gt; == &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XName&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"Assertion"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;span class="SpellE"&gt;saml&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;The App now issues the security token request to the MSO STS. However, this time instead of appending the user&amp;rsquo;s O365 credentials to the SOAP message&amp;rsquo;s security header (as in the previous post) it appends the logon token we got from the corporate ADFS. MSO STS checks the validity of the token and if everything is happy it returns a service token which we can then use to sign into SPO and get the federated authentication cookies (just like in the previous post).&lt;/p&gt;
&lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l4 level1 lfo6;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormalCxSpFirst" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// generate the WS-Trust security token request SOAP message passing in the logon token we got from the corporate ADFS&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// and the site we want access to &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;saml11RTBytes = &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Encoding&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.UTF8.GetBytes(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;ParameterizeSoapRequestTokenMsgWithAssertion(&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.spSiteUrl.ToString&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;),&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;logonToken&lt;/span&gt;&lt;/span&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;msoStsUrl&lt;/span&gt;&lt;/span&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// make the post request to MSO STS with the WS-Trust payload&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;byte&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;] response = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.SendHttpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;span class="SpellE"&gt;msoStsUrl&lt;/span&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Post&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;MemoryStream&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(saml11RTBytes),&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="GramE"&gt;application/&lt;span class="SpellE"&gt;soap+&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;xml&lt;/span&gt;; charset=utf-8"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;StreamReader&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;sr&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;StreamReader&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;MemoryStream&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(response));&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// the SAML security token is in the &lt;span class="SpellE"&gt;BinarySecurityToken&lt;/span&gt; element of the message body&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XDocument&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;xDoc&lt;/span&gt; = &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XDocument&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Parse&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;sr.ReadToEnd&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;());&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;binaryST&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;from&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;in&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;xDoc.Descendants&lt;/span&gt;()&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;e.Name&lt;/span&gt; == &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XName&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="SpellE"&gt;BinarySecurityToken&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;span class="SpellE"&gt;wsse&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;So as you notice the main difference from the previous code is we are now presenting the user&amp;rsquo;s logon token we got from the corporate ADFS to MSO STS as a proof/claim of who the user is. In this case, MSO STS is what is called a &amp;ldquo;relying party&amp;rdquo; in the claims/brokered authentication lingo and the corporate ADFS is what is called an &amp;ldquo;identity provider&amp;rdquo;. This basically means that MSO STS trusts the corporate ADFS has done its job authenticating the user and as long as the token signature is valid (hasn&amp;rsquo;t been tampered with) MSO STS will accept it as a proof of the user&amp;rsquo;s identity. Before all this code runs the trust relationship between MSO STS and the corporate ADFS should have been already established as outlined in the O365 SSO configuration references at the beginning of this post.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;And that&amp;rsquo;s it for integrated Windows Authentication! Obviously, this is the preferred method as we never have to ask users for their credentials as long as they are logged into a machine joined to their domain and are connected to the corporate network. &lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;2.&lt;span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;SSO via user&amp;rsquo;s corporate credentials&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/5126.sso_5F00_creds.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/5126.sso_5F00_creds.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;Most steps happen the same way as in the integrated with &lt;span class="SpellE"&gt;auth&lt;/span&gt; approach except that in this case we ask users for their corporate credentials to get the logon token. This normally happens when users are not connected to the corporate network. This approach requires, as mentioned previously, an ADFS proxy service deployed following O365 SSO recommended guidelines.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;The code assumes the ADFS proxy &lt;span class="SpellE"&gt;usernamemixed&lt;/span&gt; endpoint is available. The App asks for the user&amp;rsquo;s corpnet credentials and constructs a request security token message (following the WS-Trust standard). It sends the request to the &lt;span class="SpellE"&gt;usernamemixed&lt;/span&gt; endpoint and if the credentials are valid ADFS responds with the logon token. The logon token is then presented to MSO STS just as in the integrated win &lt;span class="SpellE"&gt;auth&lt;/span&gt; approach.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;private &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;async &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Task&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt; &lt;span class="SpellE"&gt;GetAdfsSAMLTokenUsernamePassword&lt;/span&gt;()&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// makes a &lt;span class="SpellE"&gt;seurity&lt;/span&gt; token request to the corporate ADFS proxy &lt;span class="SpellE"&gt;usernamemixed&lt;/span&gt; endpoint using&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// the user's corporate credentials. The logon token is used to talk to MSO STS to get&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// an O365 service token that can then be used to sign into SPO.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;samlAssertion&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// the corporate ADFS proxy endpoint that issues SAML &lt;span class="SpellE"&gt;seurity&lt;/span&gt; tokens given username/password credentials&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;stsUsernameMixedUrl&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;String&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Format(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"https://{0}/adfs/services/trust/2005/usernamemixed/"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;span class="SpellE"&gt;adfsAuthUrl.Host&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// generate the WS-Trust security token request SOAP message passing in the user's corporate credentials&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// and the site we want access to. We send the token request to the corporate ADFS proxy &lt;span class="SpellE"&gt;usernamemixed&lt;/span&gt; endpoint.&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;byte&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;] &lt;span class="SpellE"&gt;requestBody&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Encoding&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.UTF8.GetBytes(ParameterizeSoapRequestTokenMsgWithUsernamePassword(&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;urn:&lt;/span&gt;federation:MicrosoftOnline&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// we are requesting a logon token to talk to the Microsoft Federation Gateway&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.username&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.password&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;stsUsernameMixedUrl&lt;/span&gt;&lt;/span&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;try&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;byte&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;] response = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.SendHttpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;span class="SpellE"&gt;stsUsernameMixedUrl&lt;/span&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Post&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;MemoryStream&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;span class="SpellE"&gt;requestBody&lt;/span&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="GramE"&gt;application/&lt;span class="SpellE"&gt;soap+&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;xml&lt;/span&gt;; charset=utf-8"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle" style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// the logon token is in the SAML assertion element of the message body&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XDocument&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;xDoc&lt;/span&gt; = &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XDocument&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Parse&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Encoding&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.UTF8.GetString(response, 0, &lt;span class="SpellE"&gt;response.Length&lt;/span&gt;), &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;LoadOptions&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.PreserveWhitespace&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; assertion = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;from&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;in&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;xDoc.Descendants&lt;/span&gt;()&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;e.Name&lt;/span&gt; == &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XName&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"Assertion"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;span class="SpellE"&gt;saml&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;And with that we have come to the end of this post. I hope you found it useful. Oh I almost forgot :)! You can download the sample code &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/1488.MySPOWin8AppSSO.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;Happy coding.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;Legal Disclaimer:&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;Everything written in this blog represents my own views only and not those of my employer. Also, any code is provided &amp;ldquo;AS IS&amp;rdquo; without warranty of any kind either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10368831" width="1" height="1"&gt;</content><author><name>Omar Venado</name><uri>http://blogs.msdn.com/Omar-Venado/ProfileUrlRedirect.ashx</uri></author><category term="Windows 8" scheme="http://blogs.msdn.com/b/omarv/archive/tags/Windows+8/" /><category term="Office 365" scheme="http://blogs.msdn.com/b/omarv/archive/tags/Office+365/" /><category term="SharePoint Online" scheme="http://blogs.msdn.com/b/omarv/archive/tags/SharePoint+Online/" /><category term="C#" scheme="http://blogs.msdn.com/b/omarv/archive/tags/C_2300_/" /><category term="SAML" scheme="http://blogs.msdn.com/b/omarv/archive/tags/SAML/" /><category term="Auth" scheme="http://blogs.msdn.com/b/omarv/archive/tags/Auth/" /><category term="XAML" scheme="http://blogs.msdn.com/b/omarv/archive/tags/XAML/" /><category term="ADFS" scheme="http://blogs.msdn.com/b/omarv/archive/tags/ADFS/" /><category term="SSO" scheme="http://blogs.msdn.com/b/omarv/archive/tags/SSO/" /></entry><entry><title>Windows 8 Store Apps + new Office 365 Enterprise Preview (SharePoint Online)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/omarv/archive/2012/10/25/windows-8-store-apps-office-365-enterprise-preview-sharepoint-online.aspx" /><id>http://blogs.msdn.com/b/omarv/archive/2012/10/25/windows-8-store-apps-office-365-enterprise-preview-sharepoint-online.aspx</id><published>2012-10-26T02:57:00Z</published><updated>2012-10-26T02:57:00Z</updated><content type="html">&lt;p&gt;So this is my very first blog post here on MSDN blogs. Personally, I&amp;rsquo;m excited to write it as it involves 2 great Microsoft technologies I&amp;rsquo;m very passionate about: Windows 8 and the new Office 365. In this post I will cover the communication fundamentals of how to talk to the new Office 365, specifically SharePoint, from a Windows Store App. As part of the Office Division I&amp;rsquo;m particularly hyped about the new Office 365 offering and all the great value it brings to our customers. If you haven&amp;rsquo;t done so, I encourage you to sign up and check out the new Office 365 Technical Preview &lt;a href="http://www.microsoft.com/office/preview/en/try-more-products"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;div class="WordSection1"&gt;
&lt;p class="MsoNormal"&gt;Last week I decided to develop my first Windows Store App and the one thing I wanted to do was to leverage SharePoint Online as my backend service. SharePoint offers a lot of collaboration and document management capabilities as a service through its &lt;a href="http://msdn.microsoft.com/en-us/library/jj164060(v=office.15).aspx#ClientManagedOM"&gt;CSOM (Client-Side Object Model) APIs&lt;/a&gt; and the new &lt;a href="http://msdn.microsoft.com/en-us/library/fp142385(v=office.15).aspx"&gt;REST services&lt;/a&gt;. Since I&amp;rsquo;m a bit more proficient with C# than with &lt;span class="SpellE"&gt;Javascript&lt;/span&gt; the CSOM managed API seemed like the right choice. I thought it was going to be as straight forward as looking for an article on the web on how to develop a Windows Store App in C# that uses the managed CSOM API to talk to SharePoint Online. Surprisingly I was wrong. &lt;span class="SpellE"&gt;Wictor&lt;/span&gt; &lt;span class="SpellE"&gt;Wilen&amp;rsquo;s&lt;/span&gt; &lt;a href="http://www.wictorwilen.se/Post/How-to-do-active-authentication-to-Office-365-and-SharePoint-Online.aspx"&gt;article&lt;/a&gt; (great article by the way) is the closest I could find. However, there were a few challenges to make the code work for a Windows Store App:&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l3 level1 lfo1;"&gt;&lt;!--[if supportlists=""--&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;1)&lt;span style="font: small/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;1) The .NET assembly for&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;Windows Store Apps is a subset of the .NET framework so it doesn&amp;rsquo;t have all the goodies such as the WS Trust classes to communicate to the Microsoft Online Services STS.&lt;!--![if--&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l3 level1 lfo1;"&gt;&lt;!--[if supportlists=""--&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;2)&lt;span style="font: small/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Most importantly, the compiler complained that System.Web.Services.dll cannot be resolved when I referenced the CSOM &lt;span class="SpellE"&gt;dlls&lt;/span&gt; (&lt;span class="SpellE"&gt;Microsoft.SharePoint.Client&lt;/span&gt; and &lt;span class="SpellE"&gt;Microsoft.SharePoint.Client.Runtime&lt;/span&gt;). &lt;!--![if--&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;At this point I&amp;rsquo;m starting to realize this is not exactly going to be a walk in the park. Since I can&amp;rsquo;t use the managed CSOM my only alternative is to use the new SharePoint REST services. And for the authentication part &amp;hellip; well, this is pretty much what this blog post is about.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;SharePoint Online (SPO) implements a brokered authentication model where it relies on a different service to authenticate the user. This service is the Microsoft Online Services Secure Token Service (MSO STS). When a user navigates to a page in SPO they need to authenticate first. SPO will redirect the request to the MSO STS so the user can enter her credentials. After the STS validates the user&amp;rsquo;s identity it sends back a security token to the browser. The browser then presents the security token to SPO and after SPO validates the token it issues a cookie that allows the user to finally access the SharePoint page. All this is opaque to the user when done from the browser. The goal here is to allow the user to access SPO resources without leaving our Win 8 App (user experience is key) so our app needs to perform all these steps as well. Next, I will explain the code to make authenticated requests to SPO REST services but first I will tell you the code is written for illustration purposes only so I encourage you to make it more robust, elegant, etc. if you are planning to use it in your apps. Also, I must say I was learning Windows 8 App development on the go so, again, please refer to the Windows Store App samples for best patterns and practices. BTW, you can download the sample code at the end of the post if you want to give it a shot right away. Ok, now that you have been warned let&amp;rsquo;s dive into it.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;The diagram below shows the communication flow to make an authenticated REST call to an SPO site from a Windows Store App.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/5025.diagram.jpg"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/5025.diagram.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;Step 1: Prompt user for credentials and get SAML security token from MSO STS (1, 2 and 3 in the diagram above)&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;Since the WS Trust WCF classes are not included in the .NET for Windows Store Apps assembly I chose to use plain old vanilla http requests. The first thing is to ask the user for credentials and the SPO site she wants to connect to. I created a very simple page to collect such info.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/5123.login.jpg"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/5123.login.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;br /&gt;&amp;nbsp;The &amp;ldquo;Click&amp;rdquo; event handler for the &amp;ldquo;Login&amp;rdquo; button is where we are going to try to sign in the user to SPO. The authentication code is in a helper class called &amp;ldquo;&lt;span class="SpellE"&gt;SpoAuthUtility&lt;/span&gt;&amp;rdquo;. Let&amp;rsquo;s take a look:&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;async&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;void&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;loginButton_Click&lt;/span&gt;(&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;object&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; sender, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;RoutedEventArgs&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e)&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;try&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// Take the user's Office 365 credentials and &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;attempt to sign into SharePoint Online&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SpoAuthUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Create&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.siteUrlInput.Text&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;),&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.usernameInput.Text&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.passwordInput.Password&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;The create method instantiates the helper class and calls &lt;span class="SpellE"&gt;GetCookieContainer&lt;/span&gt; which gets the &lt;span class="SpellE"&gt;auth&lt;/span&gt; cookies from SPO. But first it needs to authenticate with MSO STS. This logic is encapsulated in the &lt;span class="SpellE"&gt;GetMsoStsSamlToken&lt;/span&gt; method which does 2 things:&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes;"&gt;1) &lt;/span&gt;Constructs an issue request SOAP message that conforms to the WS-Trust standard specifying a &lt;span style="background: yellow; mso-highlight: yellow;"&gt;SAML security token type&lt;/span&gt;, &lt;span style="background: lime; mso-highlight: lime;"&gt;the user&amp;rsquo;s credentials&lt;/span&gt;, and the &lt;span style="background: aqua; mso-highlight: aqua;"&gt;SPO site &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;url&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;. This is what the request security token soap message looks like:&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;s&lt;span class="GramE"&gt;:Envelope&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;xmlns:s&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;http://www.w3.org/2003/05/soap-envelope&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;xmlns:a&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;http://www.w3.org/2005/08/addressing&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;xmlns:u&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;s:&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Header&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a&lt;span class="GramE"&gt;:Action&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;s:mustUnderstand&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;1&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a:Action&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a&lt;span class="GramE"&gt;:ReplyTo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a:Address&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;http://www.w3.org/2005/08/addressing/anonymous&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a:Address&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a&lt;span class="GramE"&gt;:ReplyTo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a&lt;span class="GramE"&gt;:To&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;s:mustUnderstand&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;1&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;https://login.microsoftonline.com/extSTS.srf&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a:To&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;o&lt;span class="GramE"&gt;:Security&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;s:mustUnderstand&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;1&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;xmlns:o&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;o:&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;UsernameToken&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;o&lt;span class="GramE"&gt;:Username&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: lime; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: lime;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: lime; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: lime;"&gt;[username]&lt;/span&gt;&lt;span style="background: lime; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: lime;"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;o:Username&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;o&lt;span class="GramE"&gt;:Password&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: lime; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: lime;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: lime; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: lime;"&gt;[password]&lt;/span&gt;&lt;span style="background: lime; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: lime;"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;o:Password&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;o&lt;span class="GramE"&gt;:UsernameToken&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;o&lt;span class="GramE"&gt;:Security&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;s&lt;span class="GramE"&gt;:Header&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;s:&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Body&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;t&lt;span class="GramE"&gt;:RequestSecurityToken&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;xmlns:t&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;http://schemas.xmlsoap.org/&lt;span class="SpellE"&gt;ws&lt;/span&gt;/2005/02/trust&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;wsp&lt;span class="GramE"&gt;:AppliesTo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;xmlns:wsp&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;=&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;http://schemas.xmlsoap.org/&lt;span class="SpellE"&gt;ws&lt;/span&gt;/2004/09/policy&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a&lt;span class="GramE"&gt;:EndpointReference&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a&lt;span class="GramE"&gt;:Address&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: aqua; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: aqua;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: aqua; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: aqua;"&gt;[&lt;span class="SpellE"&gt;url&lt;/span&gt;]&lt;/span&gt;&lt;span style="background: aqua; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: aqua;"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a:Address&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;a&lt;span class="GramE"&gt;:EndpointReference&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;wsp&lt;span class="GramE"&gt;:AppliesTo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;t:KeyType&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;t:KeyType&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;t:RequestType&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;http://schemas.xmlsoap.org/ws/2005/02/trust/Issue&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;t:RequestType&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;t&lt;span class="GramE"&gt;:TokenType&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: yellow; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;"&gt;urn:oasis:names:tc:SAML:1.0:assertion&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;t:TokenType&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;t&lt;span class="GramE"&gt;:RequestSecurityToken&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;s&lt;span class="GramE"&gt;:Body&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #a31515; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;s&lt;span class="GramE"&gt;:Envelope&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;2) Makes the request to the MSO STS and extracts the security token from the body of the response&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;async&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Task&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SamlSecurityToken&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt; &lt;span class="SpellE"&gt;GetMsoStsSAMLToken&lt;/span&gt;()&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// Makes a request that conforms with the WS-Trust standard to &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// Microsoft Online Services Security Token Service to get a SAML&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// security token back so we can then use it to sign the user to SPO &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// generate the WS-Trust security token request SOAP message passing&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;in the user's credentials and the site we want access to &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;byte&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;] saml11RTBytes = &lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Encoding&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.UTF8.GetBytes(&lt;span class="SpellE"&gt;ParameterizeamlRTString&lt;/span&gt;(&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.spSiteUrl.ToString&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;), &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.username&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.password&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// make the post request to MSO STS with the WS-Trust payload&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;byte&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;] response = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.SendHttpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;span class="SpellE"&gt;msoStsUrl&lt;/span&gt;),&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Post&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;MemoryStream&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(saml11RTBytes),&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="GramE"&gt;application/&lt;span class="SpellE"&gt;soap+&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;xml&lt;/span&gt;; charset=utf-8"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;StreamReader&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;sr&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;StreamReader&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;MemoryStream&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(response));&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// the SAML security token is in the &lt;span class="SpellE"&gt;BinarySecurityToken&lt;/span&gt; element of the message body&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XDocument&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;xDoc&lt;/span&gt; = &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XDocument&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Parse&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;sr.ReadToEnd&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;());&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;binaryST&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;from&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;in&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;xDoc.Descendants&lt;/span&gt;()&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;e.Name&lt;/span&gt; == &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XName&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="SpellE"&gt;BinarySecurityToken&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;span class="SpellE"&gt;wsse&lt;/span&gt;) &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// get the security token expiration date from the message body&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; expires = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;from&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;in&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;xDoc.Descendants&lt;/span&gt;()&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;e.Name&lt;/span&gt; == &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;XName&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"Expires"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;span class="SpellE"&gt;wsu&lt;/span&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;select&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; e;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SamlSecurityToken&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;samlST&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SamlSecurityToken&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;samlST.BinarySecurityToken&lt;/span&gt; = &lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Encoding&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.UTF8.GetBytes(&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;binaryST.FirstOrDefault&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;().Value);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;samlST.Expires&lt;/span&gt; = &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;DateTime&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Parse&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;expires.FirstOrDefault&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;().Value);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;samlST&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraph"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoListParagraph"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;Step 2: Sign in the user into SPO by presenting the security token we got from the MSO STS and get the authentication cookies (4, 5 and 6 in the diagram above)&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;The &lt;span class="SpellE"&gt;GetSPOAuthCookies&lt;/span&gt; method will make a post request to SPO and get the authentication cookies which come in the response headers. There are 2 encrypted cookies that we get back from SPO: 1) the &lt;span class="SpellE"&gt;FedAuth&lt;/span&gt; cookie which is basically the cookie we need to pass along with any subsequent requests to the service and 2) the &lt;span class="SpellE"&gt;rtFA&lt;/span&gt; cookie which is necessary if we want to sign the user out.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;async&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Task&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SPOAuthCookies&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt; &lt;span class="SpellE"&gt;GetSPOAuthCookies&lt;/span&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SamlSecurityToken&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;stsToken&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;siteUri&lt;/span&gt; = &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;this&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.spSiteUrl&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;wsSigninUrl&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;String&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Format&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"{0}://{1}/{2}"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;span class="SpellE"&gt;siteUri.Scheme&lt;/span&gt;, &lt;span class="SpellE"&gt;siteUri.Authority&lt;/span&gt;, &lt;span class="SpellE"&gt;spowssigninUri&lt;/span&gt;));&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;clientHandler&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpClientHandler&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;();&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.SendHttpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;wsSigninUrl&lt;/span&gt;&lt;/span&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Post&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;MemoryStream&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;span class="SpellE"&gt;stsToken.BinarySecurityToken&lt;/span&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="GramE"&gt;application/x-www-form-&lt;span class="SpellE"&gt;urlencoded&lt;/span&gt;&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;clientHandler&lt;/span&gt;&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SPOAuthCookies&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;spoAuthCookies&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SPOAuthCookies&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;spoAuthCookies.FedAuth&lt;/span&gt; = &lt;span class="GramE"&gt;clientHandler.CookieContainer.GetCookies(&lt;/span&gt;wsSigninUrl)[&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"FedAuth"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;].Value;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;spoAuthCookies.RtFA&lt;/span&gt; = &lt;span class="GramE"&gt;clientHandler.CookieContainer.GetCookies(&lt;/span&gt;wsSigninUrl)[&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"rtFA"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;].Value;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;spoAuthCookies.Expires&lt;/span&gt; = &lt;span class="SpellE"&gt;stsToken.Expires&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;spoAuthCookies.Host&lt;/span&gt; = &lt;span class="SpellE"&gt;wsSigninUrl&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;spoAuthCookies&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;strong style="mso-bidi-font-weight: normal;"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;&lt;/strong&gt;&lt;/strong&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;strong&gt;Step 3: Make the actual &lt;span class="SpellE"&gt;OData&lt;/span&gt; request to SPO REST services, get back some goodness and render it using the Windows 8 UI (7 and 8 in the diagram above)&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;In this case I&amp;rsquo;m making a request to get all the SP lists from the site that are visible to the user from the SPO web interface. In this case I&amp;rsquo;m using a GET request. For write operations you need to use POST, PUT, and DELETE methods. I will cover a simple example on how to perform a write operation below. You can find more about the SPO REST services notation based on the &lt;span class="SpellE"&gt;OData&lt;/span&gt; protocol &lt;a href="http://msdn.microsoft.com/en-us/library/fp142385(v=office.15).aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// Send a &lt;span class="SpellE"&gt;json&lt;/span&gt; &lt;span class="SpellE"&gt;odata&lt;/span&gt; request to SPO rest services to fetch all lists in the site that are visible to the end user.&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; response = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.SendODataJsonRequest&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;String&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Format&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"{0}/_&lt;span class="SpellE"&gt;api&lt;/span&gt;/web/lists?$filter=Hidden &lt;span class="SpellE"&gt;eq&lt;/span&gt; false"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SpoAuthUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Current.SiteUrl&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;)),&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Get&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// reading data from SP through the rest &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;api&lt;/span&gt;&lt;/span&gt; usually uses the GET verb&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpClientHandler&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(),&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SpoAuthUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Current&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// pass in the helper object that allows us to make authenticated calls to SPO rest services&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;The method below simply appends the SPO authentication cookies we got earlier to the http request and specifies we want to get JSON back (&lt;span class="SpellE"&gt;OData&lt;/span&gt; will return ATOM payloads by default). JSON has become extremely popular and the .NET framework for Windows Store Apps provides some really helpful methods to parse JSON strings or implement you own custom &lt;span class="SpellE"&gt;serializer&lt;/span&gt;.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;static&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;async&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Task&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;byte&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;[]&amp;gt; &lt;span class="SpellE"&gt;SendODataJsonRequest&lt;/span&gt;(&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;uri&lt;/span&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; method, &lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Stream&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;requestContent&lt;/span&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpClientHandler&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;clientHandler&lt;/span&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SpoAuthUtility&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;authUtility&lt;/span&gt;, &lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Dictionary&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt; headers = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; (&lt;span class="SpellE"&gt;clientHandler.CookieContainer&lt;/span&gt; == &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;clientHandler.CookieContainer&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;CookieContainer&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;CookieContainer&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;cookieContainer&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;authUtility.GetCookieContainer&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;); &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// get the &lt;span class="SpellE"&gt;auth&lt;/span&gt; cookies from SPO after authenticating with Microsoft Online Services STS&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;foreach&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; (&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Cookie&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; c &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;in&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;cookieContainer.GetCookies&lt;/span&gt;(&lt;span class="SpellE"&gt;uri&lt;/span&gt;))&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;clientHandler.CookieContainer.Add&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;uri&lt;/span&gt;, c); &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// &lt;span class="SpellE"&gt;apppend&lt;/span&gt; SPO &lt;span class="SpellE"&gt;auth&lt;/span&gt; cookies to the request&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;SendHttpRequest&lt;/span&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;uri&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="GramE"&gt;method&lt;/span&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;requestContent&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="GramE"&gt;application/&lt;span class="SpellE"&gt;json;&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;odata&lt;/span&gt;=&lt;span class="SpellE"&gt;verbose;charset&lt;/span&gt;=utf-8"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// the http content type for the JSON flavor of SP REST services&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;clientHandler&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="GramE"&gt;headers&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;Finally, manipulate the JSON we got back from SPO and feed it to our app UI. The screenshots below show the lists and list items in my SkyDrive Pro (aka SharePoint MySite).&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;&lt;span style="mso-no-proof: yes;"&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/0714.home.jpg"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/0714.home.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;&lt;span style="mso-no-proof: yes;"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/3858.document.jpg"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/3858.document.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;That&amp;rsquo;s about it. Before I wrap this up 2 things:&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;1) If you want to write to SPO you need to append an additional piece of information to your REST call. It is call a dynamic canary and it is used to prevent cross site scripting attacks. You can learn more about it &lt;a href="http://msdn.microsoft.com/en-us/library/gg552614.aspx"&gt;here&lt;/a&gt;. For all practical purposes, if you do not append the canary to your REST request SharePoint will not let the write go through even if the user has all the right permissions. So here&amp;rsquo;s you do it.&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l1 level1 lfo5;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;static&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;async&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Task&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;byte&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;[]&amp;gt; &lt;span class="SpellE"&gt;SendODataJsonRequestWithCanary&lt;/span&gt;(&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;uri&lt;/span&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; method, &lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Stream&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;requestContent&lt;/span&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpClientHandler&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;clientHandler&lt;/span&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SpoAuthUtility&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; &lt;span class="SpellE"&gt;authUtility&lt;/span&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// Make a post request to {&lt;span class="SpellE"&gt;siteUri&lt;/span&gt;}/_&lt;span class="SpellE"&gt;api&lt;/span&gt;/&lt;span class="SpellE"&gt;contextinfo&lt;/span&gt; to get the canary&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; response = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.SendODataJsonRequest&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;String&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Format&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"{0}/_&lt;span class="SpellE"&gt;api&lt;/span&gt;/&lt;span class="SpellE"&gt;contextinfo&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SpoAuthUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Current.SiteUrl&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;)),&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Post&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;clientHandler&lt;/span&gt;&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SpoAuthUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Current&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Dictionary&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;String&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;IJsonValue&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt; &lt;span class="SpellE"&gt;dict&lt;/span&gt; = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Dictionary&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;IJsonValue&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.ParseJson(&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;JsonObject&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Parse(&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Encoding&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.UTF8.GetString(response, 0, &lt;span class="SpellE"&gt;response.Length&lt;/span&gt;)), &lt;span class="SpellE"&gt;dict&lt;/span&gt;); &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// parse the JSON response containing the canary&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; canary = &lt;span class="SpellE"&gt;dict&lt;/span&gt;[&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"&lt;span class="SpellE"&gt;FormDigestValue&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;].&lt;span class="SpellE"&gt;GetString&lt;/span&gt;(); &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// the canary is contained in the &lt;span class="SpellE"&gt;FormDigestValue&lt;/span&gt; of the response body&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// Make the &lt;span class="SpellE"&gt;OData&lt;/span&gt; request passing the canary in the request headers&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.SendODataJsonRequest&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;uri&lt;/span&gt;&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="GramE"&gt;method&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;requestContent&lt;/span&gt;&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;clientHandler&lt;/span&gt;&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SpoAuthUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Current&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Dictionary&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;string&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&amp;gt; { &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span class="GramE"&gt;{ &lt;span style="color: #a31515;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;X-&lt;span class="SpellE"&gt;RequestDigest&lt;/span&gt;"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, canary&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;} &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;});&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.25in; line-height: normal; mso-layout-grid-align: none;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;To get the dynamic canary you have to make a POST request to {&lt;span class="SpellE"&gt;siteUrl&lt;/span&gt;}/_&lt;span class="SpellE"&gt;api&lt;/span&gt;/&lt;span class="SpellE"&gt;contextinfo&lt;/span&gt; with an empty body. Note you still have to append the &lt;span class="SpellE"&gt;auth&lt;/span&gt; cookies to the canary request. The canary will be in the body of the response under the &lt;span class="SpellE"&gt;FormDigestValue&lt;/span&gt; element. Now that you have the canary all you need to do is to append it to the &amp;ldquo;X-&lt;span class="SpellE"&gt;RequestDigest&lt;/span&gt;&amp;rdquo; headers of your write REST request (don&amp;rsquo;t forget the &lt;span class="SpellE"&gt;auth&lt;/span&gt; cookies) and voila! You are now able to write to your SPO site. The code has an example that adds a new list to the site.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// Make a POST request to create the new SP list&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;// &lt;span class="GramE"&gt;This&lt;/span&gt; is a write call so it requires the canary to be appended to the request headers&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt; response = &lt;/span&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;await&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.SendODataJsonRequestWithCanary&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Uri&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;String&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Format&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #a31515; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;"{0}/_&lt;span class="SpellE"&gt;api&lt;/span&gt;/web/lists/"&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;, &lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SpoAuthUtility&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Current.SiteUrl&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;)),&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpMethod&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Post&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;MemoryStream&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(&lt;/span&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;Encoding&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.UTF8.GetBytes(&lt;span class="SpellE"&gt;addItemJsonString&lt;/span&gt;)),&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;HttpClientHandler&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;(),&lt;br /&gt;&lt;/span&gt;&lt;span style="background: white; color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span style="background: white; color: #2b91af; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;SpoAuthUtility&lt;/span&gt;&lt;span style="background: white; color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;.Current&lt;/span&gt;&lt;/span&gt;&lt;span style="background: white; color: black; line-height: 107%; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;"&gt;And this is what the body of the request looks like in JSON notation for adding a new document library&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt;"&gt;{&lt;br /&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;'__metadata': &lt;span class="GramE"&gt;{ 'type'&lt;/span&gt;: '&lt;span class="SpellE"&gt;SP.List&lt;/span&gt;' },&amp;nbsp;&lt;br /&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;'&lt;span class="SpellE"&gt;AllowContentTypes&lt;/span&gt;': true,&amp;nbsp;&lt;br /&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;'&lt;span class="SpellE"&gt;BaseTemplate&lt;/span&gt;': 101,&amp;nbsp;&lt;br /&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;'&lt;span class="SpellE"&gt;ContentTypesEnabled&lt;/span&gt;': true,&amp;nbsp;&lt;br /&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;'Description': 'My list description',&amp;nbsp;&lt;br /&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;'Title': '[title]' &lt;br /&gt;}&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt;"&gt;2) Finally, you can download the sample code &lt;a title="here" href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-08-25/5226.MySPOWin8App.zip"&gt;here&lt;/a&gt;. Enjoy!&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;And with that we have come to the end of this post. I hope you found it helpful. I will finish by saying I&amp;rsquo;m super enthused about Windows 8 and the new Office 365 and what they bring to end users and developers alike. I also think the combination of both is a fantastic foundation for developers to create the next generation of collaboration and productivity applications (business, education, finance, etc.) that take advantage of the new Windows 8 gorgeous touch interface plus the best collaboration platform there is with Office 365.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/b/omarv/archive/2012/11/15/developing-windows-store-apps-for-sharepoint-online-with-sso-single-sign-on.aspx"&gt;Part 2: Windows Store Apps for SharePoint Online with SSO&lt;/a&gt;.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;&lt;span style="text-decoration: underline;"&gt;Legal Disclaimer:&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong style="mso-bidi-font-weight: normal;"&gt;Everything written in this blog represents my own views only and not those of my employer. Also, any code is provided &amp;ldquo;AS IS&amp;rdquo; without warranty of any kind either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10362898" width="1" height="1"&gt;</content><author><name>Omar Venado</name><uri>http://blogs.msdn.com/Omar-Venado/ProfileUrlRedirect.ashx</uri></author><category term="Windows 8" scheme="http://blogs.msdn.com/b/omarv/archive/tags/Windows+8/" /><category term="Office 365" scheme="http://blogs.msdn.com/b/omarv/archive/tags/Office+365/" /><category term="SharePoint Online" scheme="http://blogs.msdn.com/b/omarv/archive/tags/SharePoint+Online/" /><category term="C#" scheme="http://blogs.msdn.com/b/omarv/archive/tags/C_2300_/" /><category term="SAML" scheme="http://blogs.msdn.com/b/omarv/archive/tags/SAML/" /><category term="Auth" scheme="http://blogs.msdn.com/b/omarv/archive/tags/Auth/" /><category term="XAML" scheme="http://blogs.msdn.com/b/omarv/archive/tags/XAML/" /></entry></feed>