[GH-ISSUE #777] ytmusicapi oauth CLI fails in non-interactive environments (EOFError on input()) #494

Open
opened 2026-02-27 23:01:06 +03:00 by kerem · 1 comment
Owner

Originally created by @RomanOnARiver on GitHub (Jun 15, 2025).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/777

  • I confirm that I have read the FAQ

Describe the bug

When running ytmusicapi oauth as a background subprocess (such as from a GUI app), the CLI requires the user to "press Enter" after device code authentication. This uses input(), which fails in non-interactive environments and raises EOFError, preventing oauth.json from being written.
This makes it impossible to automate authentication from a GUI or headless script.

ytmusicapi version

1.10.3

To Reproduce

Steps to reproduce the behavior:

  1. Run ytmusicapi oauth --client-id ... --client-secret ... --file ... as a subprocess with no interactive stdin (for example, from a Python script or GUI application).
  2. Complete the device login in the browser as instructed.
  3. See error:

Go to https://www.google.com/device?user_code=XXXX-XXXX-XXXX, finish the login flow and press Enter when done, Ctrl-C to abort
Traceback (most recent call last):
...
EOFError: EOF when reading a line

  1. The oauth.json file is not created.

Additional context

This blocks any attempt to automate the authentication flow in GUI apps or scripts.
Feature request: Please add a CLI flag (such as --no-confirm or --non-interactive) to allow the CLI to complete without waiting for user input after device login, or skip the input prompt in non-interactive environments.

Originally created by @RomanOnARiver on GitHub (Jun 15, 2025). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/777 - [x] I confirm that I have read the [FAQ](https://ytmusicapi.readthedocs.io/en/stable/faq.html#why-does-the-oauth-flow-block-waiting-for-input) **Describe the bug** When running `ytmusicapi oauth` as a background subprocess (such as from a GUI app), the CLI requires the user to "press Enter" after device code authentication. This uses `input()`, which fails in non-interactive environments and raises `EOFError`, preventing `oauth.json` from being written. This makes it impossible to automate authentication from a GUI or headless script. **ytmusicapi version** 1.10.3 **To Reproduce** Steps to reproduce the behavior: 1. Run `ytmusicapi oauth --client-id ... --client-secret ... --file ...` as a subprocess with no interactive stdin (for example, from a Python script or GUI application). 2. Complete the device login in the browser as instructed. 3. See error: Go to https://www.google.com/device?user_code=XXXX-XXXX-XXXX, finish the login flow and press Enter when done, Ctrl-C to abort Traceback (most recent call last): ... EOFError: EOF when reading a line 4. The `oauth.json` file is not created. **Additional context** This blocks any attempt to automate the authentication flow in GUI apps or scripts. Feature request: Please add a CLI flag (such as `--no-confirm` or `--non-interactive`) to allow the CLI to complete without waiting for user input after device login, or skip the input prompt in non-interactive environments.
Author
Owner

@sigma67 commented on GitHub (Jun 16, 2025):

PR welcome

<!-- gh-comment-id:2975220456 --> @sigma67 commented on GitHub (Jun 16, 2025): PR welcome
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#494
No description provided.