Skip to content

Token returned by create_access_token cause error 422 when given to decode_token in latest version (4.7.1) #564

Closed
@fplu

Description

@fplu

Hello,

First of all, thank you for your package—it has been incredibly useful to me!

I encountered an issue in the latest version due to a breaking change in the identity parameter for create_access_token. Specifically, the following code:

@auth_bp.route("/something", methods=["POST"])
def something() -> Tuple[Response, int]:
    from flask_jwt_extended import create_access_token, decode_token
    test = create_access_token(identity={"email": "le_baguette_au_fromage@france.fr"})
    try:
        decode_token(test)
        print("success")
    except:
        print("fail")
        return jsonify({"error": "Decode failed"}), 401

Now results in the last line (jsonify({"error": "Decode failed"}), 401) being executed.

I believe one of the following changes could address the issue:

  • Add support in decode_token for dictionaries as identity.
  • Make create_access_token raise an error when a dictionary is passed as identity.

Thanks for your time and for considering this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions