Python authlib flask - şifre akışı nasıl doğru şekilde yapılır?

Oct 26 2020

Authlib flask entegrasyonunun güzelce çalıştığı "şifre verme akışı" girişine sahibim:

@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

Ancak, içinde önceki soruya ben kullanmamayı tavsiye edildi fetch_access_tokeno şişe entegrasyon için belgelenmiş değil bu gibi ve kullanımı authorize_access_tokenyerine. Bu bir hata ile başarısız olurwerkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand. KeyError: 'code'

Öyleyse, balon entegrasyonuyla "şifre verme akışı" yapmanın doğru yolu nedir?
Herhangi bir tavsiyeye açığız.

Yanıtlar

Alias_Knagg Nov 05 2020 at 14:57

Kayıt için, @ lepture yukarıdaki yorumlarda bu kullanımın uygun olduğunu onayladı fetch_access_token.
Soruyu yanıtlandı olarak işaretleyebilmek için bu yanıtı buraya girin.