#me login

Authenticate with Memory Engine via OAuth.

#Usage

me login [space]
me login --switch
me login --device [space]
Argument Required Description
space no Space slug or name to make active after login.

#Description

Authenticates with Memory Engine and stores your credentials. There are two flows:

  • Default (browser): an OAuth 2.1 authorization-code flow with PKCE over a 127.0.0.1 loopback redirect (RFC 8252). The CLI opens your browser. Sign in through Google or GitHub if needed, check the account and callback address, then select Authorize CLI. Approval is required for each new login, even when the browser is already signed in. The browser returns to the CLI, which exchanges the code for an access and refresh token pair. This needs a browser on the same machine as the CLI. (See Switching accounts for --switch.)

  • Device (--device): the OAuth 2.0 Device Authorization Grant (RFC 8628), for headless environments — an agent harness in a sandbox, a remote SSH session, a container — where the loopback flow can't reach a local browser. The CLI prints a short URL and a code; you open the URL on any device, sign in, and enter the code, and the CLI polls until you approve. This yields a rolling session token (valid for 7 days, refreshed as you keep using the CLI) rather than an access/refresh pair; when it lapses you simply run me login --device again.

If you pass a space argument, it becomes the active space. Otherwise, if you belong to exactly one space it's selected automatically; if you belong to several, run me space use to pick one. The active space is carried as the X-Me-Space header on subsequent commands.

Login also runs the same version compatibility check as me version before starting, so an out-of-date CLI gets a clean upgrade prompt instead of failing mid-flow.

#Check the browser request

The terminal displays the actual callback address, for example http://127.0.0.1:54321/callback. Compare the complete address, including its port, with the browser approval page. Only approve if you just started me login and the addresses match. If someone sent you the link, the account is wrong, or the addresses differ, select Cancel. Run me login --switch to choose another account.

With --json or --yaml, the CLI writes a JSON record containing authorization_url and redirect_uri to stderr before opening the browser. Stdout remains reserved for the final result. With --no-browser, open authorization_url yourself and compare the browser callback address with redirect_uri.

Approval lets the requesting program act as your account within your existing permissions. The application name does not prove that the local program is the official CLI. Refresh tokens let the program continue accessing your account after you close the browser; normal automatic refresh does not require another approval.

#Options

Option Description
--switch Force the browser to re-show the sign-in page, even if it already has a session (use to switch accounts).
--device Log in without a local browser (device authorization grant). Prints a URL + code to approve on any device.
--no-browser Don't open a browser automatically — just print the URL (and the code, with --device) to open yourself. Applies to both flows (useful over SSH).

#Switching accounts

Your browser keeps its own session with the server, independent of the CLI. When that session is still valid, the sign-in page is skipped, but the approval page still shows the account that will authorize the CLI. A plain me logout followed by me login proposes the same browser account because logout only clears the CLI's local credentials, not the browser session.

To sign in as a different account (for example, switching from a personal GitHub identity to a work Google one), run:

me login --switch

--switch forces the server to re-show its sign-in page even when the browser already has a session, so you can pick a different provider or account.

--switch only applies to the browser flow — it's not supported with --device (the device flow authorizes whichever account is signed in to your browser, so me login --device --switch is rejected). To switch accounts on a headless login, sign out in the browser you'll approve from first.

#Global Options

Option Description
--server <url> Server URL (overrides ME_SERVER env and stored default)

#Notes

  • Your login credentials (the token set from either flow) are stored in your OS keychain when one is available (macOS security, Linux secret-tool); otherwise they fall back to ~/.config/me/credentials.yaml (mode 0600). Set ME_NO_KEYCHAIN=1 to force the file fallback.
  • --device is the recommended way to log in from a sandboxed agent harness or any host with no browser. The approval page lives at <server>/device. The code is always typed by hand: the page ignores a ?user_code= query parameter so a link cannot be used to phish an approval, and the approve screen warns against approving a code someone else sent you.
  • Non-secret settings (default server and per-server active space) live in ~/.config/me/config.yaml.
  • Humans authenticate with a session, not an API key — me login never creates a key. For headless/CLI use where a session isn't available you can mint a personal access token with me apikey create, or restrict one with me apikey create --allow <space>:<path>:<r|w|o>; team-owned service-account keys come from me apikey create --service <service>.
  • Use me logout to clear the session; the non-secret config is kept so re-login resumes.
  • See Harness Integrations for how machine-local harness policy uses this configuration.

#See also

  • me space -- list and switch the active space.
  • me whoami -- show your identity and active space.