Python Course test three Attribute Error

I haven't seen anyone else posting with this issue, so its probably something I did on accident that broke the test.

Nonetheless, just in case someone else runs into this issue, I am posting about it here. I have also provided feedback in the course itself with the same thing.

The issue:
Test 03 of the Python Course gives FAILED tests/03_registering_a_user__test.py::test_register_user - AttributeError: 'str' object has no attribute 'decode'

The cause:
In auth.py, the return statement in the _generate_token function has ".decode('ascii')" at the end.

I fixed this by removing that part of the return statement, as it seems to me that the next function down already decodes the token (being literally named decode_token), however I do not know if this will break anything further down the line.

I would like to know if this is intentionally part of the return statement, and if its supposed to give the attribute error. Thank you.

I encountered the same error.

I encountered the same issue, and also have issues with 'register' and 'sign in' when running the app in my browser.

Changed to JWT_SECRET_KEY in ./routes/auth.py

def register():
    ...
    dao = AuthDAO(current_app.driver, current_app.config.get("JWT_SECRET_KEY"))
    ...

def login():
    ...
    dao = AuthDAO(current_app.driver, current_app.config.get("JWT_SECRET_KEY"))
    ...

Modified _generate_token function with a try except block

def _generate_token(self, payload)
    ...
    encoded = jwt.encode(payload, self.jwt_secret, algorithm="HS256")
    try:
        return encoded.decode("ascii")
    except AttributeError:
        return encoded