migrating from abandoned flask-oauthlib to authlib
parent
c1482c2bd0
commit
43342893fd
2
setup.py
2
setup.py
|
@ -32,5 +32,5 @@ setup(
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||||
],
|
],
|
||||||
packages=['spaceauth'],
|
packages=['spaceauth'],
|
||||||
install_requires=['Flask-OAuthlib>=0.9.4', 'Flask-Login>=0.4', 'requests>=2.0', 'blinker'],
|
install_requires=['authlib', 'Flask-Login>=0.4', 'requests>=2.0', 'blinker'],
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from flask import Blueprint, request, url_for, session, redirect, abort, flash
|
from flask import Blueprint, request, url_for, session, redirect, abort, flash
|
||||||
from flask_oauthlib.client import OAuth, OAuthException
|
from authlib.integrations.flask_client import OAuth, OAuthError
|
||||||
from flask_login import LoginManager, login_user, logout_user, current_user, login_required, UserMixin
|
from flask_login import LoginManager, login_user, logout_user, current_user, login_required, UserMixin
|
||||||
from spaceauth.caps import cap_required
|
from spaceauth.caps import cap_required
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class SpaceAuth(LoginManager):
|
||||||
super(SpaceAuth, self).init_app(app)
|
super(SpaceAuth, self).init_app(app)
|
||||||
app.register_blueprint(self.blueprint, url_prefix=url_prefix)
|
app.register_blueprint(self.blueprint, url_prefix=url_prefix)
|
||||||
|
|
||||||
@app.errorhandler(OAuthException)
|
@app.errorhandler(OAuthError)
|
||||||
def errorhandler(err):
|
def errorhandler(err):
|
||||||
flash('OAuth error occured', 'error')
|
flash('OAuth error occured', 'error')
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
|
@ -56,7 +56,7 @@ class SpaceAuth(LoginManager):
|
||||||
def callback_view_handler(self):
|
def callback_view_handler(self):
|
||||||
resp = self.remote.authorized_response()
|
resp = self.remote.authorized_response()
|
||||||
if resp is None:
|
if resp is None:
|
||||||
raise OAuthException(
|
raise OAuthError(
|
||||||
'Access denied', type=request.args.get('error'))
|
'Access denied', type=request.args.get('error'))
|
||||||
|
|
||||||
# TODO encrypt token...?
|
# TODO encrypt token...?
|
||||||
|
|
Loading…
Reference in New Issue