ReferenceCLI Commands

Auth

What cdg auth login, logout, and status do, their options and requirements, and how to switch the CLI to another account.

The private beta opens soon, and CodeDAG isn't available to install yet. Join the waitlist to get in line for an invite.
Edit on GitHub

cdg auth has three commands: one signs you in to CodeDAG, one signs you out, and one shows the current account. You can run them from any directory, inside a project or not. The sign-in is stored per computer, and every project on the same computer shares it. Apart from --help, cdg auth login has one option, --no-browser, and cdg auth status has one option, --local. For why you need to sign in, which commands require it, and how long you stay signed in, see Sign-In and Account.

cdg auth login

Terminal
cdg auth login [--no-browser]

This command signs you in to CodeDAG with a Google account in your browser and saves the sign-in on this computer. The first time you sign in with a given Google account, a CodeDAG account is created for it at the same time, so you don't need to register beforehand.

Sign-in has to be completed in a browser on the same computer that runs the command, so you can't sign in from a remote SSH session, a container, or a server without a graphical interface. See Without a desktop browser.

When you run it, your browser opens the sign-in page. Finish signing in within 5 minutes; if you run out of time, run the command again. If the command exits with an error before the browser opens, this computer can't reach CodeDAG. See Sign-in fails or you keep being asked to sign in.

If you run it when you're already signed in, it goes through sign-in again. On success, the new sign-in replaces the existing one on this computer. If the new sign-in doesn't complete, the existing one stays as it is.

You don't normally need to run this command yourself. When cdg init, cdg dag submit, or cdg auth status finds that you aren't signed in, it takes you through the same sign-in first and then carries on with the original command. You mainly run it on its own when you switch accounts, or when a queued workflow has stopped at on-hold because this computer isn't signed in.

--no-browser

cdg auth login --no-browser just prints the sign-in URL and waits, without opening a browser. You can open the URL in any browser on this computer, and the CLI signs in to the account you confirm in that browser. It's useful in two situations:

  • Automated sign-in: When a script or an agent operates the browser to complete the sign-in, it can take the URL from the command's standard output and open it in the browser it operates.
  • Several CodeDAG accounts signed in to different browsers: Open the URL directly in the browser that's signed in to the account you want, without going through the default browser.

You still have to open the URL on the computer running the CLI. See Without a desktop browser.

The environment variable CODEDAG_NO_BROWSER=1 does the same, but for every command that can start a sign-in: besides cdg auth login, that includes cdg init, cdg dag submit, and cdg auth status when you aren't signed in yet. Once sign-in completes, the original command carries on as usual. In automated setups, sign-in is often started by these commands, so use the environment variable there. It accepts only 1. When it's unset or empty, the browser opens as usual.

cdg auth logout

Terminal
cdg auth logout

This command signs the CLI out on this computer and clears the sign-in saved here. Sign-ins in the web console and on other computers aren't affected. For how signing out affects queued workflows, see Sign out and switch accounts.

cdg auth status

Terminal
cdg auth status [--local]

Without options, this command shows the signed-in account, the subscription status, and credit usage for the current period. For what each item means, see Check credits and usage.

--local

cdg auth status --local reports whether you're signed in based only on the credentials saved on this computer. It makes no network requests and doesn't start browser sign-in. That makes it suitable for scripts and agents to run before a command that requires sign-in: the exit code is 0 when you're signed in and 1 when you aren't. It shows only the user ID, not the email address, subscription, or credits. If the sign-in has already been invalidated on the server, it still reports that you're signed in.

Sign out and switch accounts

To switch the CLI on this computer to another account, sign in again with the other Google account, and then confirm which account is current:

Terminal
cdg auth login
cdg auth status

For how several computers share one account, and for the full rules on signing out, see Sign out, use multiple computers, and switch accounts.

Signing out and switching accounts don't affect workflows that have already started running. When a queued workflow's turn to run comes, the CLI on this computer must be signed in to the account that submitted it. Otherwise the workflow stops at on-hold, and the workflows behind it wait too. Sign in, or switch back to the original account, and then run cdg dag recover <workflow> to continue.

  • Sign-In and Account: Which commands require sign-in, how long you stay signed in, and what data the CodeDAG service receives.
  • Credits and Subscription: Free credits, subscriptions, and when credits are deducted.
  • Troubleshooting: Find the cause by symptom when sign-in fails, when you're asked to sign in again and again, or when you end up in the wrong account after signing in.

Last updated on