JWT 401 Problem

3 Comentários

  • Greg Katechis
    Zendesk Developer Advocacy

    Hi Marcin! I checked the logs for your subdomain and it looks like the payload that you're sending is not correct. Could you please share the code snippet for the generation of the token so that we can see what might be going wrong? I also recommend using jwt.io to check that generated tokens in testing are indeed creating the correct payload.

    0
  • Marcin Krężelewski

    Hi, Thanks for your reply. Here is the snippet of JWT creation code (.NET/C#):

    var name = "m******";
    var email = "m*******@****.com";
    var securityKey = _configuration["SecurityKey"];

    var claims = new[] {
                        new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
                        new Claim(JwtRegisteredClaimNames.Name, name),
                        new Claim(JwtRegisteredClaimNames.Iat, DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64),
                        new Claim(JwtRegisteredClaimNames.Email, email),
                    };

    var handler = new JwtSecurityTokenHandler();

    var token = new JwtSecurityToken
                (
                    claims: claims,
                    signingCredentials: new SigningCredentials(new SymmetricSecurityKey(System.Text.Encoding.ASCII.GetBytes(securityKey)), SecurityAlgorithms.HmacSha256)
                );

    return base.Content(handler.WriteToken(token), "application/jwt");
    0
  • Marcin Krężelewski

    Is there any way to check myself what am I doing wrong?

    0

Por favor, entrar para comentar.

Powered by Zendesk