Skip to content

OAuth flow fails in SSH/Headless sessions - Browser cannot be opened #27300

Description

@ruchid123123

What happened?

1 ### Environment
2 - **CLI Version:** 0.42.0 (Antigravity/Gemini CLI)
3 - **OS:** Linux (VM)
4 - **Access Method:** SSH
5
6 ### Problem Statement
7 When running the CLI over an SSH session, the tool correctly detects the SSH environment:
8 `I0520 02:38:46.171139 504064 token_storage.go:50] Using file-based token storage because SSH
  session detected`
9

10 However, it still attempts to initiate a standard browser-based OAuth flow:
11 I0520 02:38:47.953528 504064 auth_manager.go:93] Starting OAuth authentication flow
12 I0520 02:38:47.953623 504064 browser.go:55] consumerOAuth: starting OAuth flow
13
14 In a headless or remote SSH environment, no browser is available. The CLI hangs or fails
because it cannot complete the authentication process.
15
16 ### Expected Behavior
17 The CLI should provide a Device Code Flow (copy-paste URL and code) or a manual token
input mechanism when an SSH session is detected, instead of attempting to open a local
browser.
18
19 ### Logs
20 (Excerpts from ~/.gemini/antigravity-cli/log/cli-*.log)
21 ...
22 W0520 02:38:46.170880 504064 log_context.go:117] Cache(loadCodeAssistResponse): Singleflight
refresh failed: error getting token source: You are not logged into Antigravity.
23 ...
24 I0520 02:38:47.953623 504064 browser.go:55] consumerOAuth: starting OAuth flow

What did you expect to happen?

1 ### Environment
2 - **CLI Version:** 0.42.0 (Antigravity/Gemini CLI)
3 - **OS:** Linux (VM)
4 - **Access Method:** SSH
5
6 ### Problem Statement
7 When running the CLI over an SSH session, the tool correctly detects the SSH environment:
8 `I0520 02:38:46.171139 504064 token_storage.go:50] Using file-based token storage because SSH
  session detected`
9

10 However, it still attempts to initiate a standard browser-based OAuth flow:
11 I0520 02:38:47.953528 504064 auth_manager.go:93] Starting OAuth authentication flow
12 I0520 02:38:47.953623 504064 browser.go:55] consumerOAuth: starting OAuth flow
13
14 In a headless or remote SSH environment, no browser is available. The CLI hangs or fails
because it cannot complete the authentication process.
15
16 ### Expected Behavior
17 The CLI should provide a Device Code Flow (copy-paste URL and code) or a manual token
input mechanism when an SSH session is detected, instead of attempting to open a local
browser.
18
19 ### Logs
20 (Excerpts from ~/.gemini/antigravity-cli/log/cli-*.log)
21 ...
22 W0520 02:38:46.170880 504064 log_context.go:117] Cache(loadCodeAssistResponse): Singleflight
refresh failed: error getting token source: You are not logged into Antigravity.
23 ...
24 I0520 02:38:47.953623 504064 browser.go:55] consumerOAuth: starting OAuth flow

Client information

1 ### Environment
2 - **CLI Version:** 0.42.0 (Antigravity/Gemini CLI)
3 - **OS:** Linux (VM)
4 - **Access Method:** SSH
5
6 ### Problem Statement
7 When running the CLI over an SSH session, the tool correctly detects the SSH environment:
8 `I0520 02:38:46.171139 504064 token_storage.go:50] Using file-based token storage because SSH
  session detected`
9

10 However, it still attempts to initiate a standard browser-based OAuth flow:
11 I0520 02:38:47.953528 504064 auth_manager.go:93] Starting OAuth authentication flow
12 I0520 02:38:47.953623 504064 browser.go:55] consumerOAuth: starting OAuth flow
13
14 In a headless or remote SSH environment, no browser is available. The CLI hangs or fails
because it cannot complete the authentication process.
15
16 ### Expected Behavior
17 The CLI should provide a Device Code Flow (copy-paste URL and code) or a manual token
input mechanism when an SSH session is detected, instead of attempting to open a local
browser.
18
19 ### Logs
20 (Excerpts from ~/.gemini/antigravity-cli/log/cli-*.log)
21 ...
22 W0520 02:38:46.170880 504064 log_context.go:117] Cache(loadCodeAssistResponse): Singleflight
refresh failed: error getting token source: You are not logged into Antigravity.
23 ...
24 I0520 02:38:47.953623 504064 browser.go:55] consumerOAuth: starting OAuth flow

Login information

1 ### Environment
2 - **CLI Version:** 0.42.0 (Antigravity/Gemini CLI)
3 - **OS:** Linux (VM)
4 - **Access Method:** SSH
5
6 ### Problem Statement
7 When running the CLI over an SSH session, the tool correctly detects the SSH environment:
8 `I0520 02:38:46.171139 504064 token_storage.go:50] Using file-based token storage because SSH
  session detected`
9

10 However, it still attempts to initiate a standard browser-based OAuth flow:
11 I0520 02:38:47.953528 504064 auth_manager.go:93] Starting OAuth authentication flow
12 I0520 02:38:47.953623 504064 browser.go:55] consumerOAuth: starting OAuth flow
13
14 In a headless or remote SSH environment, no browser is available. The CLI hangs or fails
because it cannot complete the authentication process.
15
16 ### Expected Behavior
17 The CLI should provide a Device Code Flow (copy-paste URL and code) or a manual token
input mechanism when an SSH session is detected, instead of attempting to open a local
browser.
18
19 ### Logs
20 (Excerpts from ~/.gemini/antigravity-cli/log/cli-*.log)
21 ...
22 W0520 02:38:46.170880 504064 log_context.go:117] Cache(loadCodeAssistResponse): Singleflight
refresh failed: error getting token source: You are not logged into Antigravity.
23 ...
24 I0520 02:38:47.953623 504064 browser.go:55] consumerOAuth: starting OAuth flow

Anything else we need to know?

1 ### Environment
2 - **CLI Version:** 0.42.0 (Antigravity/Gemini CLI)
3 - **OS:** Linux (VM)
4 - **Access Method:** SSH
5
6 ### Problem Statement
7 When running the CLI over an SSH session, the tool correctly detects the SSH environment:
8 `I0520 02:38:46.171139 504064 token_storage.go:50] Using file-based token storage because SSH
  session detected`
9

10 However, it still attempts to initiate a standard browser-based OAuth flow:
11 I0520 02:38:47.953528 504064 auth_manager.go:93] Starting OAuth authentication flow
12 I0520 02:38:47.953623 504064 browser.go:55] consumerOAuth: starting OAuth flow
13
14 In a headless or remote SSH environment, no browser is available. The CLI hangs or fails
because it cannot complete the authentication process.
15
16 ### Expected Behavior
17 The CLI should provide a Device Code Flow (copy-paste URL and code) or a manual token
input mechanism when an SSH session is detected, instead of attempting to open a local
browser.
18
19 ### Logs
20 (Excerpts from ~/.gemini/antigravity-cli/log/cli-*.log)
21 ...
22 W0520 02:38:46.170880 504064 log_context.go:117] Cache(loadCodeAssistResponse): Singleflight
refresh failed: error getting token source: You are not logged into Antigravity.
23 ...
24 I0520 02:38:47.953623 504064 browser.go:55] consumerOAuth: starting OAuth flow

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status
    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions