繁体   English   中英

Python authlib flask - 如何正确执行密码授予流程?

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

我有“密码授予流程”登录与 authlib 烧瓶集成工作得很好:

@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

但是,在上一个问题中,我被建议不要像这样使用fetch_access_token因为它没有记录在烧瓶集成中,而是使用authorize_access_token 这失败并出现错误werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand. KeyError: 'code' werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand. KeyError: 'code'

那么使用烧瓶集成进行“密码授予流程”的正确方法是什么?
欢迎任何建议。

作为记录, @lepture在上面的评论中确认这种使用fetch_access_token是可以的。
在此处输入此答案以将问题标记为已回答。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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