Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
06c9cff
Merge pull request #414 from AzureAD/bumping-cryptography-upper-bound
rayluo Oct 1, 2021
3062770
Merge branch 'release-1.15.0' into dev
rayluo Oct 1, 2021
62752ad
Expose http_cache parameter, with its docs and recipe.
rayluo Jul 8, 2021
fcf34a2
Merge pull request #407 from AzureAD/http-cache-parameter
rayluo Oct 15, 2021
db104d3
obtain_token_by_browser(..., auth_code_receiver=...)
rayluo Aug 14, 2021
68ef992
Merge branch 'expose-auth-code-receiver' into dev
rayluo Aug 15, 2021
45499ff
Merge remote-tracking branch 'oauth2cli_github/dev' into auth-code-re…
rayluo Oct 16, 2021
1f4ddfe
AuthCodeReceiver supports scheduled_actions now
rayluo Aug 17, 2021
6622313
Merge branch 'auth-code-receiver-scheduled-actions' into dev
rayluo Aug 18, 2021
3e2a0be
Merge remote-tracking branch 'oauth2cli/dev' into auth-code-receiver
rayluo Oct 21, 2021
0322ac7
Adding unit test cases for AuthCodeReceiver
rayluo Aug 18, 2021
dd51799
Disable allow_reuse_address when on Windows
rayluo Aug 20, 2021
ef87c00
Backport to Python 2
rayluo Aug 23, 2021
16a9a34
Merge branch 'auth-code-receiver-and-ports' into dev
rayluo Aug 24, 2021
64141ca
Merge remote-tracking branch 'oauth2cli/dev' into auth-code-receiver
rayluo Oct 27, 2021
f839dc3
Adjusts the path
rayluo Oct 27, 2021
a596b51
Merge pull request #427 from AzureAD/auth-code-receiver
rayluo Oct 28, 2021
b1ef3b9
tests/authcode.py has long been obsolete
rayluo Oct 27, 2021
24694af
Merge branch 'clean-up' into dev
rayluo Oct 28, 2021
c04e6ea
Re-enable REGION env var detection
rayluo Oct 6, 2021
56e4b01
Change Regional Endpoint to require opt-in
rayluo Oct 22, 2021
20eed4a
Merge pull request #425 from AzureAD/region-env-var
rayluo Oct 28, 2021
a7ec5b4
MSAL Python 1.16.0
rayluo Oct 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
AuthCodeReceiver supports scheduled_actions now
  • Loading branch information
rayluo committed Oct 21, 2021
commit 1f4ddfea9437b066f9e665a1f6c77fc181938b7b
13 changes: 12 additions & 1 deletion oauth2cli/authcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class _AuthCodeHttpServer6(_AuthCodeHttpServer):

class AuthCodeReceiver(object):
# This class has (rather than is) an _AuthCodeHttpServer, so it does not leak API
def __init__(self, port=None):
def __init__(self, port=None, scheduled_actions=None):
"""Create a Receiver waiting for incoming auth response.

:param port:
Expand All @@ -128,6 +128,12 @@ def __init__(self, port=None):
If your Identity Provider supports dynamic port, you can use port=0 here.
Port 0 means to use an arbitrary unused port, per this official example:
https://docs.python.org/2.7/library/socketserver.html#asynchronous-mixins

:param scheduled_actions:
For example, if the input is
``[(10, lambda: print("Got stuck during sign in? Call 800-000-0000"))]``
then the receiver would call that lambda function after
waiting the response for 10 seconds.
"""
address = "127.0.0.1" # Hardcode, for now, Not sure what to expose, yet.
# Per RFC 8252 (https://tools.ietf.org/html/rfc8252#section-8.3):
Expand All @@ -141,6 +147,7 @@ def __init__(self, port=None):
# When this server physically listens to a specific IP (as it should),
# you will still be able to specify your redirect_uri using either
# IP (e.g. 127.0.0.1) or localhost, whichever matches your registration.
self._scheduled_actions = sorted(scheduled_actions or []) # Make a copy
Server = _AuthCodeHttpServer6 if ":" in address else _AuthCodeHttpServer
# TODO: But, it would treat "localhost" or "" as IPv4.
# If pressed, we might just expose a family parameter to caller.
Expand Down Expand Up @@ -215,6 +222,10 @@ def get_auth_response(self, timeout=None, **kwargs):
time.sleep(1) # Short detection interval to make happy path responsive
if not t.is_alive(): # Then the thread has finished its job and exited
break
while (self._scheduled_actions
and time.time() - begin > self._scheduled_actions[0][0]):
_, callback = self._scheduled_actions.pop(0)
callback()
return result or None

def _get_auth_response(self, result, auth_uri=None, timeout=None, state=None,
Expand Down