Questions tagged [flask-jwt]

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

71 questions
0
votes
0 answers

JWT generated token is invalid

Here is the Flask app import jwt from datetime import datetime, timedelta from flask import Flask, request, jsonify, make_response from flask_socketio import SocketIO, send from flask_sqlalchemy import SQLAlchemy from werkzeug.security import…
0
votes
1 answer

create a function that generate a JWT token and send to server the server will verify that token and give response if token is valid

I made an API for my personal use in the Flask without any database, I want to add token authentication to that API without any user Sign Up. I want, can generate a JWT and send that to the server then Server can verify that JWT is valid then send a…
0
votes
2 answers

how to resolve a TypeError: Object of type ObjectId is not JSON serializable using flask-jwt

I have an error that I cannot resolve. here is the error I get when I authenticate with postman: TypeError: Object of type ObjectId is not JSON serializable // Werkzeug Debugger File…
0
votes
1 answer

How to pass jwt token from one route to another?

I am new to coding. I have set up a login function within Flask using flask-JWT. Thus far, I am able to login (on "/login") and a token is generated using jwt. However, I have other routes which are also protected using a wrapper (@token_required).…
helpjpls
  • 11
  • 5
0
votes
1 answer

Flask JWT with RESTful api

How to use JWT with RESTful? It works @app.route('/test_route') @jwt_required() def protected(): return '%s' % current_identity But what to do in this case? api.add_resource(testApi, '/test_api') I cannot find this case in the Flask-JWT…
R. Key
  • 178
  • 7
0
votes
0 answers

How to fetch Authorization header token to logout JWT Flask ReactJs

I'm new to Flask and React. I'm confused on how I can get the Authorization Token to logout. On Postman I can Register/login/logout a user just fine. But when it comes to getting the header Authentication 'Bearer' from the frontend I find I'm…
0
votes
0 answers

TypeError: Expecting a string- or bytes-formatted key

Am practicing API testing, and tryig to run the below test def test_login_user(self): with self.app as client: with self.app_context(): client.post('/register',data={'username':'test','password':'1234'}) …
0
votes
1 answer

Flask-JWT-Ext get_current_user(), get_jwt_identity() returns None despite having tokens

Thanks for taking a look. I am trying to implement Flask-JWT-Ext. I have redis blacklist implemented in order to revoke my tokens. I am trying to use get_current_user(), get_jwt_identity() etc but it is returning None, despite passing in the access…
anongal
  • 45
  • 2
  • 8
0
votes
1 answer

How to set a custom authorization response in Flask-JWT?

By itself, Flask-JWT works, but I need to add some values to the http response, I try to do it like this: @jwt.auth_response_callback def custom_auth_response_handler(access_token, identity): response = Response({ 'accessToken':…
kshnkvn
  • 876
  • 2
  • 18
  • 31
0
votes
0 answers

Get flask jwt token identity in other methods

I am storing userid in token, i am authenticating the token and then after getting user id validating the user is enabled or not in mysql db. So for other tables i need userid for db queries as well, so how can i get user id in those functions? is…
0
votes
1 answer

How can I add Authorization header to a request so that a flask route with @jwt_required can be access if access token is present on the headers

I'm trying to implement flask_jwt_extended to my flask app. My Use Case is, I want to set Authorization headers to every request. So that when a @jwt_required decorator is decorated to a flask route it can be access if an access token is present on…
0
votes
2 answers

"description": "Invalid credentials" in POSTMAN using flask_jwt

I am trying to authenticate and get an access token. I have created user class, I am trying to run the POST method from POSTMAN while authenticating, but I am receiving some error: { "description": "Invalid credentials", "error": "Bad Request", …
0
votes
1 answer

How to put auth functionality in @app.before_request in flask

I want to make auth layer in flask app . I was using flask-jwt-extended for jwt auth so for that i have to mentioned @jwt_requied decorator for each protected route . so i dont want to do that for each protected route. I thought to define a function…
VVK kumar
  • 267
  • 3
  • 5
  • 15
0
votes
2 answers

Flask JWT Extended "The specified alg value is not allowed" Error

When making a request to a flask route that requires a JWT to access using (@jwt_required decorator on flask-restful resources), I get a 422 UNPROCESSABLE ENTITY with the message: The specified alg value is not allowed. When logging in and…
TomHill
  • 614
  • 1
  • 10
  • 26
0
votes
1 answer

What is the mean of JWT_DEFAULT_REALM?

I am confused about the mean of JWT_DEFAULT_REALM or the mean of "The default realm" when I am using Flask_JWT. I am not a native English speaker.