-1

I saw the usage of JWT here But I am not sure where do we get the value for "key" parameter to be passed to token = jwt.encode(payload, key)

Sorry I am new to this, my requirement is to pass JWT token to my corporate URL from selenium python. Just unsure what do I pass for "key"

Ram
  • 155
  • 1
  • 5

1 Answers1

0

The key parameter can be any string, but for it to be secure, you should choose something that has sufficient randomness. (If someone can guess the key, then they can forge JWTs.)

To generate a random string that is cryptographically secure, you can use the "secrets" module in the Python standard library. The secrets.token_hex function will generate a 64-digit random hex string, which should be plenty of randomness for generating JWTs.

import secrets

key = secrets.token_hex()
Jack Taylor
  • 5,588
  • 19
  • 35