authlib

Python requests authlib - SSLCertVerificationError CERTIFICATE_VERIFY_FAILED

ぐ巨炮叔叔 提交于 2021-02-11 15:15:41
问题 How to make Autlib/ requests work with self signed certificates on Windows? There is documentation for how to use an environment variable to point to a CA bundle, but in my case I have struggled to make that work as I can not find an option to specify keystorepass or keyalias. Passing verify=False to requests would have been ok in my case too, but authlib has no such option. Suggestions for alternative solutions welcome. 回答1: The answer turned out to be hiding in plain sight. The self signed

Python authlib flask - how to do authorize_redirect explicitly?

隐身守侯 提交于 2021-01-29 08:21:06
问题 I have "code grant flow" login with the authlib flask integration working nicely: redirect_uri = url_for('authorize', _external=True) return oauth.myOauth2.authorize_redirect(redirect_uri) For some reason I decided I want to try to make the redirect a bit more visible. Show users my app for a moment before redirecting to a login page that may be more unfamiliar for some. Now this kind of works: redirect_uri = url_for('authorize', _external=True) aurl = oauth.myOauth2.create_authorization_url

Python authlib flask - how to revoke token / logout

最后都变了- 提交于 2021-01-28 05:14:46
问题 In my current situation my flask app could be the only one using the Oauth server. In that case I'd like to have my logout button actually revoke the access token. But how to do that using the authlib flask integration? Do I have to set up a new OAuth2Session just to use revoke_token() ? I don't think there is a hidden one inside FlaskRemoteApp ? And I don't think the flask registry takes a revoke_token_url or anything like that? Any advice is welcome. 回答1: Ok, here is the code that works for

Python authlib flask - how to do password grant flow correctly?

和自甴很熟 提交于 2021-01-25 06:02:00
问题 I have "password grant flow" login with the authlib flask integration working nicely: @app.route('/login', methods=('GET', 'POST')) def login(): if request.method == 'GET': return render_template('login.html') else: try: token = oauth.myOauth2.fetch_access_token(username=request.form.get('username'), password=request.form.get('password')) except OAuthError as e: if e.description: flash(e.description) return render_template('login.html') raise However, in a previous question I was advised not

Python authlib flask - how to do password grant flow correctly?

。_饼干妹妹 提交于 2021-01-25 06:01:29
问题 I have "password grant flow" login with the authlib flask integration working nicely: @app.route('/login', methods=('GET', 'POST')) def login(): if request.method == 'GET': return render_template('login.html') else: try: token = oauth.myOauth2.fetch_access_token(username=request.form.get('username'), password=request.form.get('password')) except OAuthError as e: if e.description: flash(e.description) return render_template('login.html') raise However, in a previous question I was advised not

Django REST Framework share class instance between files

老子叫甜甜 提交于 2020-12-15 04:17:46
问题 I have some code in my apps.py's ready() method that loads some Oauth providers using the authlib module. Basically I am doing this (apps.py): from django.apps import AppConfig from authlib.integrations.django_client import OAuth from django.core.cache import caches class ApiConfig(AppConfig): name = 'api' def ready(self): import api.receivers defaultcache = caches['default'] from .modules.oauth import fetch_token from .models import OauthProvider, OAuth2Token oauth = OAuth(fetch_token=fetch

Django REST Framework share class instance between files

为君一笑 提交于 2020-12-15 04:17:35
问题 I have some code in my apps.py's ready() method that loads some Oauth providers using the authlib module. Basically I am doing this (apps.py): from django.apps import AppConfig from authlib.integrations.django_client import OAuth from django.core.cache import caches class ApiConfig(AppConfig): name = 'api' def ready(self): import api.receivers defaultcache = caches['default'] from .modules.oauth import fetch_token from .models import OauthProvider, OAuth2Token oauth = OAuth(fetch_token=fetch