Note that there are some explanatory texts on larger screens.

plurals
  1. PONullReferenceException on Bootstraptoken (ACS authentication)
    text
    copied!<p>I've been following the steps to make a Windows 8 Store app get an ACS token as described here: <a href="https://stackoverflow.com/questions/12485665/does-the-webauthenticationbroker-work-in-windows-8-metro-app-post-release-candid">Does the WebAuthenticationBroker work in Windows 8 Metro App post Release Candidate</a></p> <p><strong>Authentication method of Windows 8 client</strong></p> <pre><code>private async void Authenticate() { WebAuthenticationResult webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync( WebAuthenticationOptions.None, new Uri("https://myACSnamespace.accesscontrol.windows.net:443/v2/wsfederation?wa=wsignin1.0&amp;wtrealm=http://localhost:12714/"), new Uri("http://mypublicIPaddress:80/WebAppMVCAPI/api/federation/end")); </code></pre> <p>My controller on the web application is programmed as follows:</p> <pre><code>public class FederationController : ApiController { protected virtual string ExtractBootstrapToken() { return HttpContext.Current.User.BootstrapToken(); } [HttpGet] public string Get() { return "Hello Get World"; } [HttpPost] public HttpResponseMessage Post() { var response = this.Request.CreateResponse(HttpStatusCode.Redirect); response.Headers.Add("Location", "/WebAppMVCAPI/api/federation/end?acsToken=" + ExtractBootstrapToken()); return response; } } </code></pre> <p>}</p> <p>The idea is to have the Windows 8 store app get a token from ACS with a Facebook login. When I launch the win8 client, the application shows a Facebook login page. However, the instruction <code>return HttpContext.Current.User.Bootstraptoken()</code> fails with the following exception:</p> <p><code>NullReferenceException. Object reference not set to an instance of an object.</code></p> <p>My web.config looks like this:</p> <pre><code> &lt;microsoft.identityModel&gt; &lt;service saveBootstrapTokens="true"&gt; &lt;audienceUris&gt; &lt;add value="http://localhost:80" /&gt; &lt;/audienceUris&gt; &lt;federatedAuthentication&gt; &lt;wsFederation passiveRedirectEnabled="true" issuer="https://bondsapp.accesscontrol.windows.net/v2/wsfederation" realm="http://localhost:80/" reply="http://localhost:80/" requireHttps="false" /&gt; &lt;cookieHandler requireSsl="false" path="/" /&gt; &lt;/federatedAuthentication&gt; &lt;issuerNameRegistry type="Microsoft.IdentityModel.Swt.SwtIssuerNameRegistry, Wif.Swt"&gt; &lt;trustedIssuers&gt; &lt;add name="https://bondsapp.accesscontrol.windows.net/" thumbprint="xxxxx" /&gt; &lt;/trustedIssuers&gt; &lt;/issuerNameRegistry&gt; &lt;securityTokenHandlers&gt; &lt;add type="Microsoft.IdentityModel.Swt.SwtSecurityTokenHandler, Wif.Swt" /&gt; &lt;/securityTokenHandlers&gt; &lt;issuerTokenResolver type="Microsoft.IdentityModel.Swt.SwtIssuerTokenResolver, Wif.Swt" /&gt; &lt;/service&gt; </code></pre> <p></p> <p>Can somebody shed some light on how to use the Bootstraptoken method to get an ACS token?</p> <p>Thanks Luis</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload