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

How to integrate with Flask-JWT-Extended? #206

Open
lucaam opened this issue Jun 3, 2022 · 4 comments
Open

How to integrate with Flask-JWT-Extended? #206

lucaam opened this issue Jun 3, 2022 · 4 comments

Comments

@lucaam
Copy link

lucaam commented Jun 3, 2022

Hello,

I do not find a way to integrate this library with Flask-JWT-Extended I am using in my backend. Does anyone have an example?

It works easily with the basic authentication example in the repo.

@christopherpickering
Copy link
Collaborator

Since the scheduler only runs on a single worker you might find your app works better by using the scheduler as an api that the authenticated app (multi worker) can talk to.

@lucaam
Copy link
Author

lucaam commented Jun 10, 2022

What do you mean with "using the scheduler as an api"? I did not get your comment 😔

@christopherpickering
Copy link
Collaborator

Hey, Sorry:

The flask appscheduler can be run as a standalone flask app. This can be separate from your main website. There is an api script: https://viniciuschiele.github.io/flask-apscheduler/rst/api.html

So from your jwt app, a user can be authenticated, and once they are logged in, they can have access to routes that call the API.

I built one here: https://github.com/atlas-bi/atlas-automation-hub, it has a "web app", "scheduler" > using flask app scheduler, and a "runner". My job are normally long running so I split them out from the scheduler so they don't bog it down.
I'm happy to chat if you'd like. https://discord.gg/hdz2cpygQD

@lucaam
Copy link
Author

lucaam commented Jun 10, 2022

Thanks for the fast response. I started as you did in your project "re-implementing" RestAPI to manage jobs but what I wanted to know is if there is any way to implement a different auth method (JWT instead of HTTPBasicAuth) based on the example here.

For example I expect to initialise scheduler with following parameters

SCHEDULER_API_ENABLED = True
SCHEDULER_AUTH = Authentication('bearer')

and use something like the following function to authenticate the RestAPI call

    def authenticate(auth):
        """Check JWT."""
        return is_jwt_valid(auth.get_authorization_header()[1])```

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

2 participants