Sraw
Sraw

Reputation: 20224

How to use flask-oauthlib with flask-login together?

For now, I'm trying to use flask-oauthlib with flask-login together.

flask-oauthlib provides a simple way to use oauth, but I want a login manager to automatically redirect all users who are not logged in to /login. In flask-login, I can use login_required to accomplish this. But how could I achieve this by flask-oauthlib?

Further, how to manage session when using flask-oauthlib? I understand how SSO works, but I'm confusing how could I know if this token is expired or not?

Upvotes: 1

Views: 642

Answers (1)

Bast
Bast

Reputation: 92

So, I've spent some time thinking about this (as I want to do it for my own website), and I've come up with a theoretical solution.

From what I understand in my implementation of Google's OAuth API, OAuth is about sending the user on a link to the server that hosts the OAuth keys, and then returning back to the sender. So, my idea is that in the login form, you have buttons that act as links to the OAuth client.

I haven't tested this, but since no one else has replied to this I figure this will give you a nice little project to implement yourself and let us know if it works.

Upvotes: 0

Related Questions