title: How to consume and redirect JWT token URL \login\login.php?token=jwt.goes.here using c# web application
body: <p>I am in the process of creating ASP.net core 2.0 WEB API SSO authentication using JWT. Created a  sample Controller which returns the JWT token  URL:<a href="http://localhost:50311/api/auth/token" rel="nofollow noreferrer">http://localhost:50311/api/auth/token</a></p>
  
  <ol>
  <li>How to consume JWT token using C# web application and</li>
  <li>How to redirect the page to \login\login.php?token=jwt.goes.here in C# web application </li>
  </ol>
  
  <p>Any Advice or best approach to implement this would be a great help.</p>
  
  <pre><code>namespace JWTwebAPI.Controllers
  {
      [Route("api/[controller]")]
      public class AuthController : Controller
      {
  
         [HttpPost("token")]
          public IActionResult Token()
          {
              //string tokenString = "test";
              var claimsdata = new[] { new Claim(ClaimTypes.Name, "username") };
              var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("aabbccddeeffgghh"));
              var signInCred = new SigningCredentials(key, SecurityAlgorithms.HmacSha256Signature);
              var token = new JwtSecurityToken(
                  issuer: "mysite.com",
                  audience: "mysite.com",
                  expires: DateTime.Now.AddMinutes(20),
                  claims: claimsdata,
                  signingCredentials: signInCred
                  );
              var tokenString = new JwtSecurityTokenHandler().WriteToken(token);
              return Ok(tokenString);
          }
  
      }
  }
  </code></pre>