我可以在我的Bottle应用中使用python-social-auth吗? [英] Can I use python-social-auth in my `bottle app?

查看:47
本文介绍了我可以在我的Bottle应用中使用python-social-auth吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在Web应用程序中添加一个SSO按钮。

I am going to add a SSO button to my web appication.

我要使用 python-social-auth 。但是受支持的Web框架是Django,Flask,Pyramid,Tornado,CherryPy和webpy。似乎不支持Bottle框架。

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.

如何为我的Bottle应用程序使用 python-social-auth

How to use python-social-auth for my Bottle app?

我应该创建自己的 social-auth-app-bottle 吗?


  • 如果不是那么简单的工作,哪个更好:

  • If it is not so simple work, which one is better:

  1. 移动到烧瓶

  2. 不要使用 python-social-auth (并移至其他Bottle插件,例如 bottle-rauth bottle-oauthlib 等)

  1. Move to Flask
  2. Don't use python-social-auth (and move to other Bottle plugins like bottle-rauth, bottle-oauthlib, etc)


推荐答案

我将Google的firebase用于所有内容。它具有简单的javascript元素,可将对象有效载荷提供给您的后端。我将用于一切。老实说,我发现firebase资料是管理您的登录信息的最简单,最可靠的方法。

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>

这篇关于我可以在我的Bottle应用中使用python-social-auth吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆