Usage
Description
Thehc auth status command checks your current authentication status by reading your saved credentials and validating them against the Harness API. This command confirms that you’re logged in and that your credentials are still valid.
The status check performs an actual API call to Harness services to verify your token is active and has the necessary permissions.
Flags
This command has no flags.What Gets Checked
When you runhc auth status, the CLI:
- Reads Local Config - Loads credentials from
~/.harness/auth.json - Validates Token - Checks that an API token exists
- Validates Account - Checks that an account ID exists
- API Verification - Makes a GET request to
/ng/api/accounts/{accountID} - Displays Details - Shows authentication information
Output
When Authenticated
Successful authentication displays comprehensive details:With Organization and Project
If you logged in with organization and project scope:When Not Authenticated
If you’re not logged in:When Token is Invalid
If your token has expired or been revoked:Examples
Quick Status Check
Verify you’re logged in before running commands:Verify After Login
Confirm successful authentication after login:Check Before Deployment
Validate authentication in deployment scripts:deploy.sh
CI/CD Health Check
Verify authentication in CI/CD pipelines:Multi-Account Verification
Verify which account you’re currently using:Automated Health Check Script
Monitor CLI authentication status:check-auth.sh
Status Check with JSON Parsing
Extract specific information from status:Validation Process
The status command validates credentials by:- Loading Config - Reading
~/.harness/auth.json - Checking Token - Ensuring API token is present
- Checking Account - Ensuring account ID is present
- API Call - GET request to
/ng/api/accounts/{accountID} - Response Check - Verifying 200 OK status
- Parse Response - Validating account data structure
Error Messages
Not Logged In (No Token)
Not Logged In (No Account ID)
Invalid Credentials
- Token has expired
- Token has been revoked
- Account ID doesn’t match token
- Token lacks necessary permissions
Network Issues
Timeout Error
- Network connection speed
- Firewall rules
- VPN settings
- Harness service status
Use Cases
Pre-flight Check
Verify authentication before important operations:Debug Authentication Issues
Troubleshoot login problems:Session Information Display
Show current session details in prompts:Automated Re-authentication
Auto-login if status check fails:auto-auth.sh
Exit Codes
| Exit Code | Meaning |
|---|---|
| 0 | Successfully authenticated |
| 1 | Not authenticated or validation failed |
Best Practices
- Check Before Critical Operations - Always verify auth status before important commands
- Use in Scripts - Add status checks to automation scripts
- Monitor in CI/CD - Verify authentication in pipeline steps
- Regular Checks - Periodically verify your credentials haven’t expired
- Error Handling - Properly handle status check failures in scripts
- Display in Prompts - Show auth status in shell prompts for awareness
- Log Status Output - Capture status output in logs for troubleshooting
Information Displayed
The status command shows:| Field | Description | Always Shown |
|---|---|---|
| Authentication Status | Whether you’re authenticated | Yes |
| API URL | Harness API endpoint | Yes |
| Account ID | Your Harness account identifier | Yes |
| Org ID | Organization scope (if set) | No |
| Project ID | Project scope (if set) | No |
API Request Details
The validation request:Related Commands
- hc auth login - Authenticate with Harness
- hc auth logout - Remove saved credentials
Troubleshooting
Status Shows Authenticated but Commands Fail
If status check passes but other commands fail:Intermittent Status Failures
If status check sometimes fails:- Check network stability
- Verify Harness service status
- Check for rate limiting
- Review timeout settings
Status Hangs
If the status command hangs:- Wait for the 10-second timeout
- Check network connectivity
- Verify API URL is correct
- Try with a different network