Skip to content

[Bug]: Interactive authentication does not work in Docker #5496

Closed
@phrfpeixoto

Description

@phrfpeixoto

Please confirm that you have:

  • Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
    Reproduced the issue in the latest CLI version.

In which of these areas are you experiencing a problem?

App

Expected behavior

When running shopify app dev inside a container, I expect the interactive authentication process to work seamlessly, regardless of whether there is an open TTY.

The xdg-utils package is required for the polling to work correctly:

shopify-prototype-app-1  | To run this command, log in to Shopify.
shopify-prototype-app-1  | User verification code: XXXXX-XXXX
shopify-prototype-app-1  | 👉 Open this link to start the auth process: https://accounts.shopify.com/activate-with-code?device_code%5Buser_code%5D=XXXX-XXXX
shopify-prototype-app-1  | ✔ Logged in.

This is my Dockerfile:

FROM node:18-alpine as base

EXPOSE 3000

WORKDIR /app
COPY . .

FROM base as dev

ENV NODE_ENV=development
ENV PATH="/app/node_modules/.bin:$PATH"

RUN apk --no-cache add ca-certificates wget git gcompat vim xdg-utils

RUN npm install
RUN npm run build

CMD ["shopify", "app", "dev"]

Actual behavior

Since version 3.65.0, we get an error regarding the terminal not being interactive:

shopify-prototype-app-1  | To run this command, log in to Shopify.
shopify-prototype-app-1  | ╭─ error ──────────────────────────────────────────────────────────────────────╮
shopify-prototype-app-1  | │                                                                              │
shopify-prototype-app-1  | │  Authorization is required to continue, but the current environment does     │
shopify-prototype-app-1  | │  not support interactive prompts.                                            │
shopify-prototype-app-1  | │                                                                              │
shopify-prototype-app-1  | │  To resolve this, specify credentials in your environment, or run the        │
shopify-prototype-app-1  | │  command in an interactive environment such as your local terminal.          │
shopify-prototype-app-1  | │                                                                              │
shopify-prototype-app-1  | ╰──────────────────────────────────────────────────────────────────────────────╯

Looking at the source, a change has been made to require an open TTY.
Additionally, the link is only displayed without a (IMO pointless) required keypress if the code assumes it's running in a cloud environment.

Verbose output

Verbose output
shopify-prototype-app-1  | 2025-03-10T15:24:56.347Z: Getting session store...
shopify-prototype-app-1  | 2025-03-10T15:24:56.348Z: Removing session store...
shopify-prototype-app-1  | 2025-03-10T15:24:56.350Z: Validating existing session against the scopes:
shopify-prototype-app-1  | [
shopify-prototype-app-1  |   "openid",
shopify-prototype-app-1  |   "https://api.shopify.com/auth/shop.admin.graphql",
shopify-prototype-app-1  |   "https://api.shopify.com/auth/shop.admin.themes",
shopify-prototype-app-1  |   "https://api.shopify.com/auth/partners.collaborator-relationships.readonly",
shopify-prototype-app-1  |   "https://api.shopify.com/auth/shop.storefront-renderer.devtools",
shopify-prototype-app-1  |   "https://api.shopify.com/auth/partners.app.cli.access",
shopify-prototype-app-1  |   "https://api.shopify.com/auth/destinations.readonly",
shopify-prototype-app-1  |   "https://api.shopify.com/auth/organization.store-management",
shopify-prototype-app-1  |   "https://api.shopify.com/auth/organization.apps.manage"
shopify-prototype-app-1  | ]
shopify-prototype-app-1  | For applications:
shopify-prototype-app-1  | {
shopify-prototype-app-1  |   "partnersApi": {
shopify-prototype-app-1  |     "scopes": []
shopify-prototype-app-1  |   }
shopify-prototype-app-1  | }
shopify-prototype-app-1  |
shopify-prototype-app-1  | 2025-03-10T15:24:56.350Z: Initiating the full authentication flow...
shopify-prototype-app-1  | 2025-03-10T15:24:56.350Z: Requesting device authorization code...
shopify-prototype-app-1  | 2025-03-10T15:24:56.351Z: Sending POST request to URL https://accounts.shopify.com/oauth/device_authorization
shopify-prototype-app-1  | With request headers:
shopify-prototype-app-1  |  - User-Agent: Shopify CLI; v=3.76.2
shopify-prototype-app-1  |  - Keep-Alive: timeout=30
shopify-prototype-app-1  |  - Sec-CH-UA-PLATFORM: linux
shopify-prototype-app-1  |  - Content-Type: application/json
shopify-prototype-app-1  |  - Content-type: application/x-www-form-urlencoded
shopify-prototype-app-1  |
shopify-prototype-app-1  | 2025-03-10T15:24:58.084Z: Request to https://accounts.shopify.com/oauth/device_authorization completed in 1733 ms
shopify-prototype-app-1  | With response headers:
shopify-prototype-app-1  |  - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
shopify-prototype-app-1  |  - content-type: application/json; charset=utf-8
shopify-prototype-app-1  |  - etag: W/"3be2e87b1d077789558d3e10b3ff16b6"
shopify-prototype-app-1  |  - server-timing: processing;dur=73, socket_queue;dur=2.189, edge;dur=0.045, util;dur=0.1, cfRequestDuration;dur=187.999964
shopify-prototype-app-1  |  - x-request-id: REDACTED
shopify-prototype-app-1  |
shopify-prototype-app-1  | 2025-03-10T15:24:58.085Z: Received device authorization code: {
shopify-prototype-app-1  |   "verification_uri": "https://shopify.com/activate",
shopify-prototype-app-1  |   "verification_uri_complete": "https://accounts.shopify.com/activate-with-code?device_code%5Buser_code%5D=REDACTED",
shopify-prototype-app-1  |   "expires_in": 600,
shopify-prototype-app-1  |   "interval": 5,
shopify-prototype-app-1  |   "device_code": "01616b78-7508-4d60-b931-68e15be67723",
shopify-prototype-app-1  |   "user_code": "REDACTED"
shopify-prototype-app-1  | }
shopify-prototype-app-1  |
shopify-prototype-app-1  | To run this command, log in to Shopify.
shopify-prototype-app-1  | ╭─ error ──────────────────────────────────────────────────────────────────────╮
shopify-prototype-app-1  | │                                                                              │
shopify-prototype-app-1  | │  Authorization is required to continue, but the current environment does     │
shopify-prototype-app-1  | │  not support interactive prompts.                                            │
shopify-prototype-app-1  | │                                                                              │
shopify-prototype-app-1  | │  To resolve this, specify credentials in your environment, or run the        │
shopify-prototype-app-1  | │  command in an interactive environment such as your local terminal.          │
shopify-prototype-app-1  | │                                                                              │
shopify-prototype-app-1  | ╰──────────────────────────────────────────────────────────────────────────────╯
shopify-prototype-app-1  |
shopify-prototype-app-1  | 2025-03-10T15:24:58.095Z: Running system process:
shopify-prototype-app-1  |   · Command: npm prefix
shopify-prototype-app-1  |   · Working directory: /app
shopify-prototype-app-1  |
shopify-prototype-app-1  | 2025-03-10T15:24:58.191Z: Obtaining the dependency manager in directory /app...
shopify-prototype-app-1  | 2025-03-10T15:24:58.306Z: Getting session store...
shopify-prototype-app-1  | 2025-03-10T15:24:58.307Z: Getting session store...
shopify-prototype-app-1  | 2025-03-10T15:24:59.756Z: Request to https://monorail-edge.shopifysvc.com/v1/produce completed in 1446 ms
shopify-prototype-app-1  | With response headers:
shopify-prototype-app-1  |  - x-request-id: REDACTED
shopify-prototype-app-1  |
shopify-prototype-app-1  | 2025-03-10T15:24:59.757Z: Analytics event sent: {
shopify-prototype-app-1  |   "command": "app dev",
shopify-prototype-app-1  |   "time_start": 1741620296306,
shopify-prototype-app-1  |   "time_end": 1741620298091,
shopify-prototype-app-1  |   "total_time": 1785,
shopify-prototype-app-1  |   "success": false,
shopify-prototype-app-1  |   "cli_version": "3.76.2",
shopify-prototype-app-1  |   "ruby_version": "",
shopify-prototype-app-1  |   "node_version": "18.20.4",
shopify-prototype-app-1  |   "is_employee": false,
shopify-prototype-app-1  |   "uname": "linux arm64",
shopify-prototype-app-1  |   "env_ci": false,
shopify-prototype-app-1  |   "env_plugin_installed_any_custom": false,
shopify-prototype-app-1  |   "env_plugin_installed_shopify": "[\"@shopify/cli\"]",
shopify-prototype-app-1  |   "env_shell": "sh",
shopify-prototype-app-1  |   "env_device_id": "REDACTED",
shopify-prototype-app-1  |   "env_cloud": "localhost",
shopify-prototype-app-1  |   "env_package_manager": "npm",
shopify-prototype-app-1  |   "env_is_global": false,
shopify-prototype-app-1  |   "env_auth_method": "none",
shopify-prototype-app-1  |   "cmd_app_warning_api_key_deprecation_displayed": true,
shopify-prototype-app-1  |   "cmd_all_timing_network_ms": 1733,
shopify-prototype-app-1  |   "cmd_all_timing_prompts_ms": 0,
shopify-prototype-app-1  |   "cmd_all_launcher": "npm",
shopify-prototype-app-1  |   "cmd_all_topic": "app",
shopify-prototype-app-1  |   "cmd_all_plugin": "@shopify/app",
shopify-prototype-app-1  |   "cmd_all_verbose": true,
shopify-prototype-app-1  |   "cmd_all_path_override": true,
shopify-prototype-app-1  |   "cmd_all_path_override_hash": "0c35eebf403cf91fe77a64921d76aa1ca6411d20",
shopify-prototype-app-1  |   "cmd_app_dependency_installation_skipped": false,
shopify-prototype-app-1  |   "cmd_app_reset_used": false,
shopify-prototype-app-1  |   "cmd_dev_tunnel_type": "cloudflare",
shopify-prototype-app-1  |   "cmd_all_timing_active_ms": 51,
shopify-prototype-app-1  |   "cmd_all_exit": "expected_error",
shopify-prototype-app-1  |   "user_id": "unknown",
shopify-prototype-app-1  |   "request_ids": [],
shopify-prototype-app-1  |   "args": "--verbose",
shopify-prototype-app-1  |   "error_message": "Authorization is required to continue, but the current environment does not support interactive prompts.",
shopify-prototype-app-1  |   "env_plugin_installed_all": "[\"@shopify/cli\"]",
shopify-prototype-app-1  |   "metadata": "{\"extraPublic\":{},\"extraSensitive\":{}}"
shopify-prototype-app-1  | }
shopify-prototype-app-1  | 2025-03-10T15:24:59.839Z: Reporting handled error to Bugsnag: Authorization is required to continue, but the current environment does not support interactive prompts.
shopify-prototype-app-1 exited with code 1

Reproduction steps

  1. Bootstrap the sample typescript project. Ensure CLI version is set to latest
  2. Build the Docker file and run it with with the required ENV vars
  3. Run the container

Operating System

MacOS Sonoma 15.3.1 using Docker Desktop 23.0.5

Shopify CLI version (shopify --version)

3.76.2

Shell

sh

Node version (run node -v if you're not sure)

18.20.4

What language and version are you using in your application?

N/A

Activity

isaacroldan

isaacroldan commented on Mar 14, 2025

@isaacroldan
Contributor

Hi @phrfpeixoto, I have a fix, can you try with this snapshot version and see if it works for you?

@shopify/cli@0.0.0-snapshot-20250314103137
phrfpeixoto

phrfpeixoto commented on Mar 17, 2025

@phrfpeixoto
Author

@isaacroldan That works! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      [Bug]: Interactive authentication does not work in Docker · Issue #5496 · Shopify/cli