Tokens are not strings. If you use new String(nextToken) to encode a token into a string, information about the token is lost. As a result, the token becomes invalid.

If you need to persist nextToken or transfer nextToken to the frontend page, you can use Base64 to encode nextToken into a string.