title: Returning User Roles to an AngularJS app from ASP.NET Identity using OAuth and bearer tokens
body: <p>I'm implementing an AngularJS SPA with a backend implemented as a WebAPI seeded from a Visual Studio 2013 template. AngularJS does everything including login and I've successfully got it submitting to //localhost/token and received back a token which I add to subsequent request headers. However, I now want to make decisions on what AngularJS templates to render based on the users role(s) and therefore I need the role(s) client-side (I'm securing all my server code by role so having these decisions made client-side is fine.)</p>
  
  <p>To that end I'm thinking of adding something along the lines of this...</p>
  
  <pre><code>foreach (var claim in context.Identity.Claims.Where(c =&gt; c.Type.EndsWith("/role")))
  {
      context.AdditionalResponseParameters.Add("role", claim.Value);
  }
  </code></pre>
  
  <p>... to the ApplicationOAuthProvider.TokenEndpoint() method so that the role(s) are added to the JSON that's returned back to the AngularJS code when the token is fetched.</p>
  
  <p>I realise the code above doesn't work for more that one role at the moment but I'm more interested in knowing if this is the correct way to access role information and whether I'm adding it in the correct fashion?</p>