title: How can I get the claimsidentity of a token or from an token oauth2
body: <p>I need one of my drivers to access certain information stored in the ClaimsIdentity.
  Below my method GrantResourceOwnerCredentials().</p>
  
  <pre><code>public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
  {
      context.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
      string rol = null;
      if (context.Request.Headers.ContainsKey("X-Role"))
      {
          rol = context.Request.Headers.Get("X-Role");
          switch (rol)
          {
              case "user":
                  bool isValidCredentials = await //Logica que verifica credenciales.
                  if (isValidCredentials)
                  {
                      //Crea y prepara el objeto ClaimsIdentity
                      var identity = new ClaimsIdentity(OAuthDefaults.AuthenticationType);
                      identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
                      identity.AddClaim(new Claim(ClaimTypes.Role, "user"));
                      var data = new Dictionary&lt;string, string&gt;
                      {
                          {"email", context.UserName}
                      };
                      var properties = new AuthenticationProperties(data);
                      var ticket = new AuthenticationTicket(identity, properties);
                      context.Validated(ticket);
                      return;
                  }
                  else
                  {
                      context.SetError("Invalid user or password.");
                      return;
                  }
              case "things":
                  //Logica para autenticar things.
                  return;
              default:
                  context.SetError("The role is not valid.");
                  return;
          }
      }
      else
      {
          context.SetError("The role header is required.");
          return;
      }
  }
  </code></pre>
  
  <p>Part of the code of the controller dodne I need to have access to the claims is below</p>
  
  <pre><code>    [Route("{email}")]
      [Authorize(Roles="user")]
      public async Task&lt;Customer&gt; Get([FromUri]  string email)
      {
          //here I need to obtain the value of the claim that refers to userName associated with this identity.
  
  
      }
  </code></pre>
  
  <p>How could this behavior be achieved? I know that at least the value of Role is being obtained since this makes [Authorize (Roles = "user")] work.</p>