Skip to content

Commit 8cc6d51

Browse files
committed
Fixes bug with the config passed to the "limited-input device" auth flow (#6142)
* Motivation for features / changes There's a bug in the limited-input device auth flow. The tests did not catch this issue because the config is read from a JSON string, and the test was using an "already parsed" config (dictionary), with a different structure from the json downloaded from our GCP project. * Technical description of changes Unwraps the parsed client_config from the "installed" layer, and updates test with a "realistic" configuration (which uses this structure). * Screenshots of UI changes N/A * Detailed steps to verify changes work correctly (as executed by you) Ran both auth flows manually (with and without browser), and updated tests. * Alternate designs / implementations considered N/A
1 parent 5ad9b7a commit 8cc6d51

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

tensorboard/uploader/auth.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ class _LimitedInputDeviceAuthFlow:
251251
"""
252252

253253
def __init__(self, client_config, scopes):
254-
self._client_config = client_config
254+
# The config is loaded from a json string from the GCP project, which
255+
# comes with an "installed" wrapper layer on the values we need.
256+
self._client_config = client_config["installed"]
255257
self._scopes = scopes
256258

257259
def run(self) -> google.oauth2.credentials.Credentials:

tensorboard/uploader/auth_test.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,20 @@ def json(self):
252252

253253

254254
class LimitedInputDeviceAuthFlowTest(tb_test.TestCase):
255-
_OAUTH_CONFIG = {
256-
"client_id": "console_client_id",
257-
"token_uri": "https://google.com/token",
258-
"client_secret": "console_client_secret",
259-
}
255+
# A "realistic" JSON client config string, like the ones we download from
256+
# our GCP project.
257+
_OAUTH_CONFIG_JSON = """
258+
{
259+
"installed":{
260+
"client_id":"console_client_id",
261+
"project_id":"some GCP cloud project id",
262+
"auth_uri":"https://accounts.google.com/o/oauth2/auth",
263+
"token_uri":"https://google.com/token",
264+
"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
265+
"client_secret":"console_client_secret"
266+
}
267+
}
268+
"""
260269

261270
_SCOPES = ["email", "openid"]
262271

@@ -300,8 +309,9 @@ def setUp(self):
300309
mock.patch.object(requests, "post", autospec=True)
301310
)
302311

312+
client_config = json.loads(self._OAUTH_CONFIG_JSON)
303313
self.flow = auth._LimitedInputDeviceAuthFlow(
304-
self._OAUTH_CONFIG,
314+
client_config,
305315
self._SCOPES,
306316
)
307317

0 commit comments

Comments
 (0)