Skip to content

Commit 249adeb

Browse files
authored
Detect chromium lockfile issue and fallback to device code login (#196)
1 parent 8b85a62 commit 249adeb

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/sumo/wrapper/_auth_provider.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import platform
2+
from pathlib import Path
13
import msal
24
import os
35
from datetime import datetime, timedelta
@@ -415,4 +417,16 @@ def get_auth_provider(
415417
):
416418
return AuthProviderManaged(resource_id)
417419
# ELSE
420+
lockfile_path = Path.home() / ".config/chromium/SingletonLock"
421+
if Path(lockfile_path).is_symlink() and not str(
422+
Path(lockfile_path).resolve()
423+
).__contains__(platform.node()):
424+
# https://github.com/equinor/sumo-wrapper-python/issues/193
425+
print(
426+
"Chromium lockfile points to another host, "
427+
f"you should delete {lockfile_path}. "
428+
"Falling back to device-code login now"
429+
)
430+
return AuthProviderDeviceCode(client_id, authority, resource_id)
431+
# ELSE
418432
return AuthProviderInteractive(client_id, authority, resource_id)

0 commit comments

Comments
 (0)