platform docker

Inside a Docker container, the authentication callback to localhost used by the standard clasp login command may not be reachable from the browser on the host. This article explains how to log in using the --no-localhost option, which does not require a local callback server.

Thumbnail

Environment

  • clasp 3.3.0

Use –no-localhost in Docker

Run the following command to log in from a Docker container:

npx clasp login --no-localhost

With --no-localhost, clasp does not start a local server for the authentication callback. Instead, you manually paste the authentication result into the terminal.

Login Steps

  1. Open the authentication URL displayed in the terminal in a browser on the host.
  2. Sign in to your Google account and grant the permissions required by clasp.
  3. After authentication, copy the redirect URL displayed in the browser.
  4. Paste the URL into the terminal where clasp is waiting, then press Enter.

After login completes, the credentials are saved to ~/.clasprc.json in the container’s home directory.

Reference

This article was generated by Cursor from a Cursor session log.

Related articles