Can I use python-social-auth in my `bottle app?

此生再无相见时 提交于 2020-01-04 06:51:46

问题


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:
    1. Move to Flask
    2. Don't use python-social-auth (and move to other Bottle plugins like bottle-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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!