Python application creates a token using HS512 algo and a secret key that both the applications already know. For payload, a login ID is used which is known to both the applications. The token is sent to the java application for validation but it gives Auth Error. But if I paste the token on JWT debugger portal and select the secret checkbox in the screenshot below, it changes the token a bit and this token when sent to the java application is authenticated successfully.
I tried to encode the secret key in Python using base64 and generate a new token to send to the java application but there is no change in the outcome. In fact, when I paste this new token in JWT debugger, select the secret checkbox which changes the token, and pass the new token to java application, it is successfully authenticated.
Library used in Java - io.jsonwebtoken.Jwts
Library used in Python - PyJWT
Token generation in Python
def encode_jwt():
jwt_secret_key = "some-secret-key"
data = {'sub': 'loginid'}
encoded=jwt.encode(data, jwt_secret_key, 'HS512')
return encoded
What should be changed in the Python token creation so the token can be authenticated in the Java application?