Skip to content

fix: use the real application object for Flask#869

Open
nblock wants to merge 1 commit intoauthlib:mainfrom
nblock:flask
Open

fix: use the real application object for Flask#869
nblock wants to merge 1 commit intoauthlib:mainfrom
nblock:flask

Conversation

@nblock
Copy link

@nblock nblock commented Mar 9, 2026

According to Flask's documentation one needs to use the real application object instead of current_app [1]:

Passing Proxies as Senders

Never pass current_app as sender to a signal. Use
current_app._get_current_object() instead. The reason for this is that
current_app is a proxy and not the real application object.

[1] https://flask.palletsprojects.com/en/stable/signals/ (towards the end)


What kind of change does this PR introduce?

A bugfix to reliably receive signals. It makes the example in https://docs.authlib.org/en/latest/client/flask.html#auto-update-token-via-signal work.

See #245

Checklist

  • The commits follow the conventional commits specification.
  • You ran the linters with prek.
  • You wrote unit test to demonstrate the bug you are fixing, or to stress the feature you are bringing.
  • You reached 100% of code coverage on the code you edited, without abusive use of pragma: no cover
  • If this PR is about a new feature, or a behavior change, you have updated the documentation accordingly.

  • You consent that the copyright of your pull request source code belongs to Authlib's author.

According to Flask's documentation one needs to use the real application
object instead of `current_app` [1]:

  Passing Proxies as Senders

  Never pass current_app as sender to a signal. Use
  current_app._get_current_object() instead. The reason for this is that
  current_app is a proxy and not the real application object.

[1] https://flask.palletsprojects.com/en/stable/signals/ (towards the end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant