简体   繁体   中英

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

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)

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM