title: How to implement otp authorization in asp.net core web api?
body: <p>I want to authorize users of my asp.net core web api with mobile number only with Asp.NetCore Identity. When they try to login with phone number an otp will send to the number. If they provide correct otp then token will be generated. I want to use my own sms api to send sms.</p>
  
  <p>Here is my token generation code.
  This method is called after SignIn.</p>
  
  <pre><code>private string GenerateAuthToken(ApplicationUser user)
          {
              var claims = new List&lt;Claim&gt;
              {
                  new Claim(JwtRegisteredClaimNames.Sub, user.UserName),
                  new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
                  new Claim(ClaimTypes.NameIdentifier, user.Id)
              };
  
              var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["JwtKey"]));
              var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
              var expires = Utilities.StaticProperties.GetCurrentDateTime().AddDays(Convert.ToDouble(_configuration["JwtExpireDays"]));
  
              var token = new JwtSecurityToken(
                  _configuration["JwtIssuer"],
                  _configuration["JwtIssuer"],
                  claims,
                  expires: expires,
                  signingCredentials: creds);
  
              var tokenString = new JwtSecurityTokenHandler().WriteToken(token);
              return tokenString;
          }
  </code></pre>