auto generate jwt token for channel preview (#1588)

This commit is contained in:
Jason Dove
2024-01-31 15:08:23 -06:00
committed by GitHub
parent e0aa44d41b
commit d9bbe4df1b
3 changed files with 16 additions and 8 deletions
+13
View File
@@ -1,3 +1,4 @@
using System.IdentityModel.Tokens.Jwt;
using System.Text;
using Microsoft.IdentityModel.Tokens;
@@ -17,4 +18,16 @@ public static class JwtHelper
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(issuerSigningKey!));
}
}
public static string GenerateToken()
{
var tokenHandler = new JwtSecurityTokenHandler();
var tokenDescriptor = new SecurityTokenDescriptor
{
Expires = DateTime.UtcNow.AddDays(1),
SigningCredentials = new SigningCredentials(IssuerSigningKey, SecurityAlgorithms.HmacSha256Signature)
};
SecurityToken token = tokenHandler.CreateToken(tokenDescriptor);
return tokenHandler.WriteToken(token);
}
}