Skip to content

See who grim acts as

$ grim auth:whoami

A private module refuses to clone, or you have sat down at a machine someone else set up. Before anything else you want to know whether grim holds a token here, and whose. grim auth:whoami answers that and changes nothing.

Usage

$ grim auth:whoami                        # who, and which token
$ grim auth:whoami || grim auth:login     # log in only when nothing is stored

It runs from anywhere. The exit code is 0 with a token and 1 without, so a script can test it.

Arguments and options

Show current authenticated user

Usage

grim auth:whoami

What it actually does

  1. Reads ~/.grim/config.json. Nothing else. GitHub is not contacted.
  2. Prints one line. Authenticated as anna (token: ghp_****abcd): the stored user name, then the first four and the last four characters of the token.

With no token it prints Not authenticated. Run `grim auth:login` first. and exits with 1.

Pitfalls

A stored token is not a working token

An expired or revoked token still reads as authenticated, because the check is local. When GitHub answers 401 in another command, run grim auth:login again. That one validates the token against GitHub.

An environment token hides the stored one

With GRIM_GITHUB_TOKEN exported, the masked token you see is the one from the environment, while the user name still comes from the file. The two may not belong together. Unset the variable to see what is stored.

After it finishes

Nothing has changed. If the name is not yours, log in again and the stored token is replaced.

Recipes that use it