whoami - Authentication Status

Overview

The whoami command displays your current authentication status and user information. It shows whether you’re authenticated, which authentication method you’re using, and your user details. This is useful for verifying authentication, troubleshooting access issues, and confirming which account you’re using.

Syntax

nmbl whoami

Output

The command shows:

Examples

Check Authentication Status

nmbl whoami

Shows current authentication details.

Verify After Login

# Login
nmbl login

# Verify it worked
nmbl whoami

Confirm successful authentication.

Check Before Running Commands

# Verify authentication first
nmbl whoami

# Then run authenticated command
nmbl cc src/

Troubleshoot Authentication Issues

# Check current status
nmbl whoami

# If not authenticated, login
nmbl login

# Verify again
nmbl whoami

Use Cases

Initial Setup Verification

# After first install and login
dotnet tool install --global nmbl
nmbl login
nmbl whoami

Confirm authentication is configured correctly.

Multiple Account Management

# Check which account you're using
nmbl whoami

# If wrong account, switch
nmbl logout
nmbl login
nmbl whoami

CI/CD Debugging

# In a CI/CD script
nmbl whoami

# Shows if authentication is properly configured

Team Collaboration

# When helping a teammate, ask them to run
nmbl whoami

# To diagnose authentication issues

Pre-Flight Check

# Before starting work
nmbl whoami
nmbl --version

Verify your environment is properly configured.

Authentication States

Authenticated with OAuth

Authenticated: Yes
Method: OAuth (Google)
Email: user@example.com
Name: John Doe
Token Expires: 2024-12-31 23:59:59

Authenticated with License Key

Authenticated: Yes
Method: License Key
Organization: Acme Corp
License Type: Team
License Expires: 2025-12-31

Not Authenticated

Authenticated: No
Status: Please run 'nmbl login' to authenticate

Troubleshooting

Shows “Not Authenticated”

If you expected to be authenticated:

# Try logging in
nmbl login

# Verify
nmbl whoami

Shows Wrong Account

If the wrong account is shown:

# Logout
nmbl logout

# Login with correct account
nmbl login

# Verify
nmbl whoami

Token Expired

If token is expired:

# Re-authenticate
nmbl login

# Check new expiry
nmbl whoami

Integration with Other Commands

Script Usage

#!/bin/bash
# Check authentication before running commands

if ! nmbl whoami | grep -q "Authenticated: Yes"; then
  echo "Please authenticate first:"
  nmbl login
  exit 1
fi

# Proceed with commands
nmbl cc src/
nmbl deps MySolution.slnx --output deps.svg

CI/CD Pipeline

# In GitHub Actions, Azure DevOps, etc.
steps:
  - name: Check Authentication
    run: nmbl whoami
  
  - name: Run Analysis
    run: nmbl cc src/

Makefile Integration

.PHONY: check-auth analyze

check-auth:
	@nmbl whoami | grep -q "Authenticated: Yes" || (echo "Please run: nmbl login" && exit 1)

analyze: check-auth
	nmbl cc src/
	nmbl cogc src/
	nmbl todos src/

Best Practices

Include in Scripts

# Always check auth in automated scripts
nmbl whoami || exit 1

Document for Team

# In team documentation:
# "Run 'nmbl whoami' to verify authentication"

Regular Checks

# Periodically verify authentication
nmbl whoami

Environment Setup Scripts

#!/bin/bash
# setup-dev-env.sh

echo "Setting up development environment..."

# Check nmbl installation
if ! command -v nmbl &> /dev/null; then
  echo "Installing nmbl..."
  dotnet tool install --global nmbl
fi

# Check authentication
echo "Checking authentication..."
if ! nmbl whoami | grep -q "Authenticated: Yes"; then
  echo "Please authenticate:"
  nmbl login
fi

echo "Setup complete!"
nmbl whoami