Missing or badly formatted authorization token

Always get this error during device token validation.

Are there any ideas why it's happening?

Here is the snipped of the code below I use for JWT generation.

import time
import jwt


private_key = """-----BEGIN PRIVATE KEY-----
mykey
-----END PRIVATE KEY-----"""

data = {
    "iss": "my_team_id",
    "iat": int(time.time()),
}

headers = {
    "kid": "my_key_id",
}

jwt_token = jwt.encode(
    payload=data,
    key=private_key,
    algorithm="ES256",
    headers=headers
)

print(jwt_token)