I've implemented the resource owner password grant and trying to add the IssuedAt Claim to my JWT Token. But when the token is generated, the "iat" claim is not coming. Code Snippet
var claims = new List<Claim>
{
new Claim(JwtClaimTypes.Id, user.Id.ToString()),
new Claim(JwtClaimTypes.Email, user.Email),
new Claim(JwtClaimTypes.Name, user.UserName),
new Claim(JwtClaimTypes.IssuedAt, DateTime.UtcNow.ToEpochTime().ToString(), ClaimValueTypes.Integer64),
};
Cannot figure out why Identity server is not inserting the iat (issued at) claim.
ApiResource below
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
new ApiResource("ecapi", "eCommerce API")
{ ApiSecrets = { new Secret(clientSecret.Sha256()) } },
};
}
Client is defined as below
new Client
{
ClientId = "resourceOwner",
ClientSecrets =
{
new Secret(clientSecret.Sha256())
},
AccessTokenType = AccessTokenType.Jwt,
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
AccessTokenLifetime = 1000,
AllowOfflineAccess = true,
AllowedScopes =
{
"offline_access",
"ecapi",
}
}
Updated Claims list
var claims = new List<Claim>
{
new Claim(JwtClaimTypes.Id, user.Id.ToString()),
new Claim(JwtClaimTypes.Email, user.Email),
new Claim(JwtClaimTypes.Name, user.UserName),
};