title: How do I access Microsoft.Owin.Security.xyz OnAuthenticated context AddClaims values?
body: <p>I'm trying to retrieve user properties that are returned as the OnAuthenticated context and added as a claims following this example:  <a href="https://stackoverflow.com/questions/18942196/how-to-access-facebook-private-information-by-using-asp-net-identity-owin">How to access Facebook private information by using ASP.NET Identity (OWIN)?</a></p>
  
  <p>I can see that data I am expecting is being returned at login and is being added as a Claim within Starup.Auth.cs.  But, when I am within the Account Controller, the only claims that appears within the UserManager or UserStore is issued by LOCAL AUTHORITY.  No claims can be found for Facebook (or other external providers).  Where do the claims added to context end up? (I'm using VS2013 RTM.)</p>
  
  <p>Full source and live site on Azure linked here: <a href="https://github.com/johndpalm/IdentityUserPropertiesSample/tree/VS2013rtm" rel="nofollow noreferrer">https://github.com/johndpalm/IdentityUserPropertiesSample/tree/VS2013rtm</a></p>
  
  <p>Here is what I have in Startup.Auth.cs:</p>
  
  <pre><code>var facebookOptions = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions()
  {
      AppId = ConfigurationManager.AppSettings.Get("FacebookAppId"),
      AppSecret = ConfigurationManager.AppSettings.Get("FacebookAppSecret"),
      Provider = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationProvider()
      {
          OnAuthenticated = (context) =&gt;
              {
                  const string XmlSchemaString = "http://www.w3.org/2001/XMLSchema#string";
                  foreach (var x in context.User)
                  {
                      var claimType = string.Format("urn:facebook:{0}", x.Key);
                      string claimValue = x.Value.ToString();
                      if (!context.Identity.HasClaim(claimType, claimValue))
                          context.Identity.AddClaim(new System.Security.Claims.Claim(claimType, claimValue, XmlSchemaString, "Facebook"));
  
                  }
                  context.Identity.AddClaim(new System.Security.Claims.Claim("urn:facebook:access_token", context.AccessToken, XmlSchemaString, "Facebook"));
                  return Task.FromResult(0);
              }
      }
  
  };
  
  facebookOptions.Scope.Add("email");
  
  app.UseFacebookAuthentication(facebookOptions);
  </code></pre>
  
  <p>An alternative way to capture the external login properties would be to add a single claim for the access token and populate it with properties:</p>
  
  <pre><code>const string XmlSchemaString = "http://www.w3.org/2001/XMLSchema#string";
  var facebookOptions = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions
  {
      AppId = ConfigurationManager.AppSettings.Get("FacebookAppId"),
      AppSecret = ConfigurationManager.AppSettings.Get("FacebookAppSecret"),
      Provider = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationProvider()
      {
          OnAuthenticated = (context) =&gt;
          {
              var claim = new System.Security.Claims.Claim("urn:facebook:access_token", context.AccessToken, XmlSchemaString, "Facebook");
              foreach (var x in context.User)
              {
                  string key = string.Format("urn:facebook:{0}", x.Key);
                  string value = x.Value.ToString();
                  claim.Properties.Add(key, value);
              }
  
              context.Identity.AddClaim(claim);
  
              return Task.FromResult(0);
          }
      }
  };
  </code></pre>
  
  <p>NOTE - This sample does not work: Though it would be nice to pass a single claim with properties.  The external cookie seems to note honor the claims properties.  The properties are empty when retrieving them later from the identity.</p>