Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connexion jwt support #607

Closed
ctippur opened this issue Jun 21, 2018 · 4 comments
Closed

Connexion jwt support #607

ctippur opened this issue Jun 21, 2018 · 4 comments

Comments

@ctippur
Copy link

ctippur commented Jun 21, 2018

Description

Wondering if there is support for jwt auth via connexion

Expected behaviour

Should be a way to authenticate jwt token, I am unable to find a way to initialize jwt token via the flask app.

Actual behaviour

I get an error:

raise RuntimeError("You must initialize a JWTManager with this flask "
RuntimeError: You must initialize a JWTManager with this flask application before using this method

I see an issue reported earlier but I was not sure if it led to a conclusion.

#124

Appreciate if I could get a working example of the same (if any)

Additional info:

Output of the commands:

  • python --version
    3.6.2
  • pip show connexion | grep "^Version\:"
    Version: 1.1.9
@bobh66
Copy link

bobh66 commented Jun 21, 2018

Did you try flask_jwt_extended:

from flask_jwt_extended import JWTManager

app.config['JWT_SECRET_KEY'] = 'jwt-secret-string'

jwt = JWTManager(app)

@ctippur
Copy link
Author

ctippur commented Jun 21, 2018

Yes. I tried to use that.
I get an error trying to use the below line of code:
access_token = create_access_token(identity=username)

raise RuntimeError("You must initialize a JWTManager with this flask "
RuntimeError: You must initialize a JWTManager with this flask application before using this method

@ctippur
Copy link
Author

ctippur commented Jun 21, 2018

I am using the below code in my controller

pp=connexion.FlaskApp(__name__).app
# Setup the Flask-JWT-Extended extension
app.config['JWT_SECRET_KEY'] = 'super-secret'  # Change this!
app.config['JWT_TOKEN_LOCATION'] = ['cookies','header']
jwt = JWTManager(app)

@dtkav
Copy link
Collaborator

dtkav commented Dec 17, 2018

JWT auth was introduced with #732 and is available in connexion 2.0.x

@dtkav dtkav closed this as completed Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants