Python Generate Secret or API Key

May 28, 2019

Command Line

python -c 'import secrets; print(secrets.token_urlsafe(32))'
6TqNEbz1o6b95wdjr3wY6M6zZFdyivmfUPANBA-xrc4

Python Code

import secrets

SECRET = secrets.token_urlsafe(32)

NOTE: secrets require Python 3.6

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.