问题
I am going to add a SSO button to my web appication.
I want to use python-social-auth
for it. But the supported web frameworks are Django, Flask, Pyramid, Tornado, CherryPy and webpy. It seems to not support Bottle framework.
How to use python-social-auth
for my Bottle app?
Should I create my own social-auth-app-bottle
?
- If it is not so simple work, which one is better:
- Move to Flask
- Don't use
python-social-auth
(and move to other Bottle plugins likebottle-rauth
,bottle-oauthlib
, etc)
回答1:
I use firebase from Google for everything. It has simple javascript elements that feed an object payload to your backend. I use bottle
for EVERYTHING. And honestly I found the firebase stuff the easiest and most robust way to manage your logins.
import firebase_admin
from firebase_admin import credentials, auth as firebase_auth
cred = credentials.Certificate("<yours>-adminsdk-AAAAA-1234567.json")
firebase_admin.initialize_app(cred)
def checkToken(token):
try:
return firebase_auth.verify_id_token(token)
except:
return False
def login(payload):
user = checkToken(payload['token']) or redirect('/logout')
# <your code here>
来源:https://stackoverflow.com/questions/59495193/can-i-use-python-social-auth-in-my-bottle-app