lingthio / Flask-User

Customizable User Authorization & User Management: Register, Confirm, Login, Change username/password, Forgot password and more.
http://flask-user.readthedocs.io/
MIT License
1.06k stars 294 forks source link

UnicodeDecodeError: 'ascii' codec can't decode byte #215

Open OlegZv opened 6 years ago

OlegZv commented 6 years ago

In Flask-User 1.0.1.4(python 2.7) when starting an app, Flask-User throws an error:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.3\helpers\pydev\pydevd.py", line 1599, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.3\helpers\pydev\pydevd.py", line 1026, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:/AutomatedTesting/run.py", line 1, in <module>
    from auto_device_testing import app
  File "C:/AutomatedTesting\auto_device_testing\__init__.py", line 11, in <module>
    from views import main
  File "C:/AutomatedTesting\auto_device_testing\views.py", line 10, in <module>
    user_manager = UserManager(app, db, User)
  File "C:\Users\ozvona413\AutomatedTesting\lib\site-packages\flask_user\user_manager.py", line 56, in __init__
    self.init_app(app, db, UserClass, **kwargs)
  File "C:\Users\ozvona413\AutomatedTesting\lib\site-packages\flask_user\user_manager.py", line 197, in init_app
    self.token_manager = TokenManager(app)
  File "C:\Users\ozvona413\AutomatedTesting\lib\site-packages\flask_user\token_manager.py", line 46, in __init__
    key = flask_secret_key.encode()
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8c in position 2: ordinal not in range(128)

SEKRETKEY="?A\x8c\x0cX\xf2K%]J!i\x97\x84\xd2\xddb\x8d\x8a\xe7\x9b+\x1d"

Tried to change flask_secret_key.encode() to flask_secret_key.encode('utf-8') but it threw the save error.

and-semakin commented 4 years ago

Looks relevant to https://github.com/lingthio/Flask-User/pull/229