shopify-auth

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: MIT

README

shopify-auth

shopify-auth is a small Go wrapper for switching between Shopify CLI accounts using memorable local profile names.

$ shopify-auth use work
Current account: developer@example.com.
Using profile "work" (developer@example.com).

It delegates authentication to Shopify CLI's native multi-account support. Shopify CLI owns and refreshes the credentials; shopify-auth never reads, copies, or stores access tokens.

Requirements

  • Shopify CLI with the auth login --alias flag (verified with 4.5.2)
  • Go 1.22 or newer only when installing with go install or building from source

Install Shopify CLI if needed:

npm install -g @shopify/cli@latest

Install

brew install frknue/tap/shopify-auth

Homebrew keeps shopify-auth updated with brew upgrade. If Shopify CLI is not installed yet, install its official formula as well:

brew install shopify/shopify/shopify-cli
Go
go install github.com/frknue/shopify-auth/cmd/shopify-auth@latest

Make sure Go's bin directory is on PATH.

Release binaries

Prebuilt archives for macOS, Linux, and Windows are available on the GitHub Releases page. Download the archive for your operating system and architecture, then place the shopify-auth executable somewhere on PATH.

Build from source
git clone https://github.com/frknue/shopify-auth.git
cd shopify-auth
make build
./bin/shopify-auth --help

Usage

Run use without a name to choose a profile or add an account:

$ shopify-auth use
? Choose a profile
> work (developer@example.com)
  personal (personal@example.com)
  Add account

Use the ↑/↓ arrow keys and press Enter. When standard input or output is redirected, the command falls back to a numbered prompt for compatibility.

You can also switch directly by profile name:

shopify-auth use work
shopify-auth use personal

When creating a profile, enter a name such as work, choose or log in to the account using Shopify's native arrow-key picker. shopify-auth captures the account Shopify confirms and creates a mapping such as workdeveloper@example.com; there is no alias to retype.

Shopify's --alias flag selects an existing session rather than renaming it. See the auth login command reference.

List saved profiles:

$ shopify-auth list
* work             developer@example.com
  personal         personal@example.com

The * marks the last selected profile. Shopify CLI doesn't currently expose an auth list command, so this mapping is maintained by shopify-auth; it contains no tokens.

Every saved switch is verified against Shopify CLI's reported Current account: value before the local profile is marked current. If Shopify no longer knows a saved alias, the native picker opens once so the mapping can be repaired.

All later shopify ... commands use the selected account. To remove every saved Shopify CLI session (with confirmation):

shopify-auth logout

For scripts, the confirmation can be skipped explicitly with shopify-auth logout --force.

logout is Shopify CLI's global logout operation; it removes all saved account sessions, not only the currently selected one.

Run shopify-auth --help for the complete command list.

How it works

After resolving a local profile, the switch is equivalent to:

shopify auth login --alias developer@example.com

Using Shopify's public command keeps this tool independent of the CLI's private credential format and the operating system keychain implementation. For the list command, it stores only profile names, Shopify session aliases, and the last selected profile in the operating system's user configuration directory. Writes are atomic and locked so simultaneous commands cannot overwrite one another. Older name-only configurations are preserved and linked through the native Shopify picker when selected. Set SHOPIFY_AUTH_CONFIG to override the metadata file location.

Development

go test ./...
go test -race ./...
go vet ./...

License

MIT

Directories

Path Synopsis
cmd
shopify-auth command
internal
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL