question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: jwt_required() missing 1 required positional argument: 'fn'

See original GitHub issue

Whenever I use the decorator jwt_required() I get this error

Traceback (most recent call last): File "app.py", line 2, in <module> from api.db import * File "/home/d4vinci/******/******/Project/******/api/db.py", line 51, in <module> @jwt_required() TypeError: jwt_required() missing 1 required positional argument: 'fn'

and this is my auth function ` @app.route(‘/api/db/auth’,methods=[‘POST’]) def auth(): if not request.is_json: return jsonify({“msg”: “Missing JSON in request”}), 400

email = request.json.get('email', None)
password = request.json.get('password', None)
if not username:
    return jsonify({"msg": "Missing email parameter"}), 400
if not password:
    return jsonify({"msg": "Missing password parameter"}), 400

if email in [ u.email for u in User.objects.all()]:
    return jsonify({"msg": "Bad username or password"}), 401
elif verify_hash(password,User.objects.filter(email=email).password):
    return jsonify({"msg": "Bad username or password"}), 401

access_token = create_access_token(identity=username+password+"*"*5)
return jsonify(access_token=access_token), 200

`

and the function with the decorator is @app.route("/api/db/whoami") @jwt_required() def who(): current_user = get_jwt_identity() return jsonify(logged_in_as=current_user), 200 `

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

21reactions
vimalloc-mavenlinkcommented, Feb 16, 2021

Prior to the 4.0.0 release of flask-jwt-extended, @jwt_required was the right decorator to use. On version 4.0.0 and above, @jwt_requried() should be used instead. See https://flask-jwt-extended.readthedocs.io/en/stable/v4_upgrade_guide/ for all the breaking changes of this release.

12reactions
vimalloccommented, Jul 19, 2018

Use @jwt_required instead of @jwt_required().

Read more comments on GitHub >

github_iconTop Results From Across the Web

python decorator TypeError missing 1 required positional ...
Understand what decorator is: @exponential_backoff def test(): pass. equals to: def test(): pass test = exponential_backoff(test).
Read more >
wrapper() missing 1 required positional argument: 'fn' - ...
The Python TypeError: init () missing 1 required positional argument occurs when we forget to provide a required argument when instantiating a class....
Read more >
flask_jwt — Flask-JWT 0.3.2 documentation
This is done automatically for you by `jwt_required()` but you could call it ... This function receives one positional argument being the JWT...
Read more >
API Documentation
The decorated function must take one argument. The argument is the identity that was used when creating a JWT. The decorated function must...
Read more >
wrapper() missing 1 required positional argument: 'fn'
TypeError : Register() missing 1 required positional argument: 'request'. Python By Vivek Dhage on May 24 2022. from django.http import JsonResponse from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found