Vat Viwat
Vat Viwat

Reputation: 1

JWT token does not begin with Bearer String

I got a warning message like this "JWT token does not begin with Bearer String" before I generate the token, and it's also more warning like this when I open swagger.

warning

Upvotes: 0

Views: 7709

Answers (1)

gaetan224
gaetan224

Reputation: 646

your have to provide the Bearer String, must of the libraries out there provide and automatic way of doing that, for example with io.jsonwebtoken

        long now = (new Date()).getTime();
String token = Jwts.builder()
                 .setSubject("username")
                 .claim("roles", "ROLE_ADMIN, ROLE_USER")
                 .signWith(key, SignatureAlgorithm.HS512)
                 .setExpiration(new Date(now + 86400))
                 .compact();

here token starts with Bearer

Upvotes: 3

Related Questions