Io.jsonwebtoken.malformedjwtexception: jwt strings must contain exactly 2 period characters. found: 0

            <div>
                <code>
                    <pre>
io.jsonwebtoken.malformedjwtexception: jwt strings must contain exactly 2 period characters. found: 0

This error message is thrown when the JWT (JSON Web Token) string doesn't have the correct format. JWT strings consist of three parts separated by period characters (.).

Example of JWT format: XXXXX.YYYYY.ZZZZZ

In this example, XXXXX represents the header, YYYYY represents the payload, and ZZZZZ represents the signature. Each part should be base64 encoded and separated by a period character.

The error message specifically states that it found 0 period characters in the JWT string, which means the string doesn't have the necessary structure. This could occur due to various reasons, including:

1. Missing or extra characters in the string.
2. Incorrectly encoded parts.
3. Incorrectly concatenated parts.

To fix the error, make sure your JWT string follows the correct format. Here's an example of a correctly formatted JWT:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

In this example, the JWT string has all three required parts (header, payload, and signature) properly encoded and separated by period characters.

Remember that the error "jwt strings must contain exactly 2 period characters. found: 0" indicates that your JWT string is not properly structured and lacks the necessary period characters.
                    </pre>
                </code>
            </div>
        

Similar post

Leave a comment