Fixes #693, a regression in oauthenticator v16 introduced by replacing requests to make a sync web request with tornado's HTTPClient. With it, we can re-use tornado configured OAuthenticator.http_request_kwargs instead of configuring something similar for requests.
This code was extracted and tested to work from a ipython prompt locally with adjustments like this, and also by running a jupyterhub. The @default function is called when a user signs in for the first time, not before tornado's event loop has started.
If there is a smoother way to use the existing async OAuthenticator.httpfetch function from this sync context, doing something like asyncio.run, we should probably do that - but for example asyncio.run doesn't end up working as HTTPClient conflicts with the current event loop.
Fixes #693, a regression in oauthenticator v16 introduced by replacing
requests
to make a sync web request with tornado's HTTPClient. With it, we can re-use tornado configuredOAuthenticator.http_request_kwargs
instead of configuring something similar forrequests
.This code was extracted and tested to work from a
ipython
prompt locally with adjustments like this, and also by running ajupyterhub
. The@default
function is called when a user signs in for the first time, not before tornado's event loop has started.If there is a smoother way to use the existing
async OAuthenticator.httpfetch
function from this sync context, doing something likeasyncio.run
, we should probably do that - but for exampleasyncio.run
doesn't end up working asHTTPClient
conflicts with the current event loop.