-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace deprecated flask-oauthlib with authlib (#1411)
* Replace flask-oauthlib with authlib Flask-oauthlib has been deprecated by its maintainer; authlib is the recommended successor. * Update examples with changes required by authlib. * Update documentation to reference authlib.
- Loading branch information
kdwyer
authored
Jul 3, 2020
1 parent
c5ca06b
commit 85567d5
Showing
6 changed files
with
103 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from flask import redirect, session | ||
from flask_appbuilder import expose | ||
from flask_appbuilder.security.views import AuthOAuthView | ||
from flask_appbuilder.security.sqla.manager import SecurityManager | ||
|
||
|
||
class MyAuthOAuthView(AuthOAuthView): | ||
|
||
@expose("/logout/") | ||
def logout(self): | ||
"""Delete access token before logging out.""" | ||
session.pop('oauth_token', None) | ||
return super().logout() | ||
|
||
|
||
class MySecurityManager(SecurityManager): | ||
authoauthview = MyAuthOAuthView | ||
|
||
def set_oauth_session(self, provider, oauth_response): | ||
"""Store the ouath token in the session for later retrieval. | ||
In this example, the token is only required to send a tweet. | ||
""" | ||
res = super().set_oauth_session(provider, oauth_response) | ||
# DON'T DO THIS IN PRODUCTION, SAVE TO A DB IN PRODUCTION | ||
if provider == "twitter": | ||
session["oauth_token"] = oauth_response | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters