title: AspNet Identity 2: Customize OAuth endpoint response
body: <p>I successfully implemented my custom <code>OAuthAuthorizationServerProvider</code>. But when I log in and retrieve a token, my client doesn't have any idea of the user's roles, claims, etc.</p>
  
  <p>I currently added a webapi controller to return the list of the principal's claims, but I'm not really happy with that.</p>
  
  <p>When requesting a token, the current response looks like:</p>
  
  <pre><code>{
      access_token: "qefelgrebjhzefilrgo4583535",
      token_type: "bearer",
      expires_in: 59
  }
  </code></pre>
  
  <p><strong>Q> How can make it return something like the following snippet?</strong></p>
  
  <pre><code>{
      access_token: "qefelgrebjhzefilrgo4583535",
      token_type: "bearer",
      expires_in: 59,
      user: {
          name: 'foo',
          role: 'bar'
      }
  }
  </code></pre>
  
  <p><strong>My progress so far:</strong></p>
  
  <p>The documentation of <code>OAuthAuthorizationServerProvider#TokenEndpoint(OAuthTokenEndpointContext)</code> says:</p>
  
  <blockquote>
    <p>Called at the final stage of a successful Token endpoint request. An application
    may implement this call in order to do any final modification of the claims
    being used to issue access or refresh tokens. This call may also be used
    in order to add additional response parameters to the Token endpoint's json
    response body.</p>
  </blockquote>
  
  <p>I couldn't find any example of how to customize the response, and asp-net Identity's source code is not yet released, so I'm quite stuck.</p>