authlibフラスコ統合がうまく機能している「コード付与フロー」ログインがあります。
redirect_uri = url_for('authorize', _external=True)
return oauth.myOauth2.authorize_redirect(redirect_uri)
何らかの理由で、リダイレクトをもう少し見やすくすることにしました。ログイン ページにリダイレクトする前に、少しの間ユーザーに私のアプリを表示します。
今、この種の作品:
redirect_uri = url_for('authorize', _external=True)
aurl = oauth.myOauth2.create_authorization_url(redirect_uri)
# what to do with aurl['state']?
return render_template('redirect.html', delay=2,
redirect_notice='Redirecting to login',
redirect_url=aurl['url'])
ただし、ログイン後に「承認」にリダイレクトされると、authlib.integrations.base_client.errors.MismatchingStateError: mismatching_state: CSRF Warning! State not equal in request and response.
保存しなかったことが原因であると推測されますaurl['state']
。
しかし、どうすれば実際にそれを行うことができますか? authorize_redirect がどのようにそれを行うかを理解するのに苦労しています。
多分もっと良い方法がありますか?どんな助けでも大歓迎です!