Questions tagged [flask-jwt]

JWT (JSON Web Tokens) for Flask applications. MIT-licensed.

71 questions
1
vote
1 answer

How can I set a persistent JWT token header in flask?

I can't seem to find a way to set the JWT Token as a header in each HTTP Request without the help of Javascript. Currently I have my application setup to use the methods 'set_access_cookies' and 'unset_access_cookies' to keep track of the session.…
BlackAperture
  • 69
  • 1
  • 8
1
vote
2 answers

Is it possible to change the _default_jwt_payload_handler(identity) by code?

I'm having problems using Flask-JWT in my application, I am using the authenticate and identity like this: def authenticate(username, password): session = db.Session() user = session.query(db.Operators).filter_by(username= username).first() if…
Zichittella
  • 31
  • 1
  • 8
1
vote
3 answers

getting error while using Flask JWT, AttributeError: 'list' object has no attribute 'id' and shows 500 Internal server error

security.py from user import User from werkzeug.security import safe_str_cmp users =[User(1,'abc','abc') ] username_mapping = {u.username:u for u in users} userid_mapping = {u.uid: u for u in users} def…
Abhishek Parmar
  • 287
  • 2
  • 8
  • 21
1
vote
1 answer

Redirecting to a page that requires authentication

I'm using JS client-side and Flask server-side. I have a login page that uses Flask-JWT as the security. After I send the credentials to my server and receive the JWT, I save it in localStorage. How do I then redirect to a page that is protected and…
Hackerman
  • 1,289
  • 1
  • 14
  • 29
1
vote
1 answer

Flask-jwt How DO I specify authorization after successful authentication

I'm using flask, flask-jwt and flask-restful. I can get the access_token , but once any user gets authenticated he can do everything to all database tables using the REST-API endpoint , how can I implement authorization where certain user can do…
1
vote
1 answer

how to send access token directly through browser

This is my fuction for accepting a HTTP GET request: class Test2(Resource): @jwt_required def get(self): mailid = request.args.get('mailid', '') username = request.args.get('username', '') …
nithish albin
  • 61
  • 1
  • 9
1
vote
1 answer

I'm getting an error while using Flask_JWT with Mongoengine 'dict' object has no attribute 'id'

My User Model looks like this class UserModel(Document): first_name = StringField(required=True, max_length=50) last_name = StringField(required=True, max_length=50) username = StringField(required=True) password =…
Joseph Vargas
  • 772
  • 5
  • 17
1
vote
1 answer

Flask-jwt-extended doesn't support required claims?

I'm using flask-jwt-extended over flask-jwt but there doesn't seem to be support for requiring claims. Is this something I have to implement myself in a new identity function and if so how do I override the existing functionality in…
James MV
  • 8,569
  • 17
  • 65
  • 96
1
vote
0 answers

Using Flask-JWT with pytest

I am trying to test the /auth endpoint in a Flask application that uses the Flask-JWT module. import json import pytest @pytest.mark.usefixtures("testapp") class TestURLs: def test_auth(self, testapp): rv = testapp.get('/auth', …
ChrisGuest
  • 3,398
  • 4
  • 32
  • 53
1
vote
1 answer

Flask-JWT generates error when Debug=False

I am playing around with Flask. I have created an API using Flask-Restful and Flask-JWT. When Debug=True in Flask, and I do not send the Authorization Header, I get the response as However, when the debug=False, the response returned is Internal…
user6354393
1
vote
1 answer

flask-jwt response 401 UNAUTHORIZED even with assess_token sent in request

I first try to test flask-jwt on my local machine, by using flask's built-in server. I request http:/localhost/auth with my username and password as payload it works fine, and I got a token. Then I request a protected API with this token, say with…
franky
  • 53
  • 10
1
vote
1 answer

TypeError: Expecting a string- or bytes-formatted key when using Flask-JWT

I have a question about flask python. I tried learning how to build a web using flask, and there is some error. In this case I am using mongoengine as database and JWT(Json Web Token) and the alert error is like this: "TypeError: Expecting a string-…
Stefani Johnsson
  • 381
  • 1
  • 5
  • 18
1
vote
0 answers

Flask Restless Preprocessors: GET_MANY doesn't works (auth REST API with Flask-Security)

Documentation is ambiguous, sometimes GET_MANY and other GET_COLLECTION are used. I need to make a preprocessor to authorize. GET_SINGLE does work (return 401: forbiden), but GET_MANY or GET_COLLECTION does not (return 200:…
1
vote
0 answers

Apidoc for Flask-JWT's authentication url

I have started using apidoc for generating REST api documentation. I have tried different things with it. In my flask based api application, I use JWT (flask-jwt in particular) for authentication. The doc gets generated properly, but the request…
Hussain
  • 5,057
  • 6
  • 45
  • 71
0
votes
0 answers

Flask JWT token authentication error while username/password authentication works fine

I am trying to implement JWT token authentication for my Flask Rest project. When I authenticate using username and password I get generated token: http --auth test:testpass POST http://localhost:5000/api/v1/account/token HTTP/1.1 200…
ussrback
  • 491
  • 2
  • 8
  • 22