From fa9ba86e5e232326d7072c211f20a487da71a38c Mon Sep 17 00:00:00 2001 From: Arthur Eigenbrot Date: Fri, 12 Aug 2022 08:59:15 -0600 Subject: [PATCH 1/3] Fix checking for reauth condition for new globus API (v3) --- dkist/net/globus/auth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dkist/net/globus/auth.py b/dkist/net/globus/auth.py index 78aadd03..089c98f4 100644 --- a/dkist/net/globus/auth.py +++ b/dkist/net/globus/auth.py @@ -208,7 +208,7 @@ def do_reauth(*args, **kwargs): try: return func(*args, **kwargs) except globus_sdk.AuthAPIError as e: - if e.http_status == 400 and e.message == "invalid_grant": + if e.http_status == 400 and "invalid_grant" in e.message: print("Globus login has expired.") get_refresh_token_authorizer(force_reauth=True) return func(*args, **kwargs) From bd0777a76f2bc8617b0a99f24fb2600eba8548ae Mon Sep 17 00:00:00 2001 From: Arthur Eigenbrot Date: Fri, 12 Aug 2022 09:05:58 -0600 Subject: [PATCH 2/3] Add changelog fragment --- changelog/197.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/197.bugfix.rst diff --git a/changelog/197.bugfix.rst b/changelog/197.bugfix.rst new file mode 100644 index 00000000..61556b0c --- /dev/null +++ b/changelog/197.bugfix.rst @@ -0,0 +1 @@ +Successfully ask for re-authentication when Globus token is stale. From fdb77e47e33e37b37ecdf6a4ca76ad26e78bbc67 Mon Sep 17 00:00:00 2001 From: Arthur Eigenbrot Date: Fri, 12 Aug 2022 09:11:00 -0600 Subject: [PATCH 3/3] Add test coverage to the reauth failure that caused this fix --- dkist/net/globus/tests/test_auth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dkist/net/globus/tests/test_auth.py b/dkist/net/globus/tests/test_auth.py index f7252f66..f63ea9c3 100644 --- a/dkist/net/globus/tests/test_auth.py +++ b/dkist/net/globus/tests/test_auth.py @@ -107,7 +107,7 @@ def test_get_refresh_token_authorizer(mocker): def test_ensure_auth_decorator(mocker): error = globus_sdk.AuthAPIError(mocker.MagicMock()) mocker.patch.object(error, "http_status", 400) - mocker.patch.object(error, "message", "invalid_grant") + mocker.patch.object(error, "message", '{"error":"invalid_grant"}') reauth = mocker.patch("dkist.net.globus.auth.get_refresh_token_authorizer") called = [False]