Command Reference link
Complete documentation for all Entra Token CLI commands, options, and arguments.
Command Overview link
get-token link
Generate an access token using a configured profile.
Synopsis link
1
| entratool get-token [OPTIONS]
|
| Option | Alias | Required | Description |
|---|
--profile <NAME> | -p | Yes | Profile name to use |
--scope <SCOPE> | -s | No | Override profile scope |
--flow <FLOW> | -f | No | OAuth2 flow to use |
--silent | | No | Suppress output except token |
--output <FILE> | -o | No | Save token to file |
--json | | No | Output as JSON |
OAuth2 Flows link
ClientCredentials - Service-to-serviceAuthorizationCode - Web applicationsDeviceCode - Limited-input devicesInteractiveBrowser - Desktop applications
Examples link
Basic usage:
1
| entratool get-token -p my-profile
|
Override scope:
1
2
| entratool get-token -p my-profile \
--scope "https://graph.microsoft.com/User.Read Mail.Read"
|
Specify flow:
1
| entratool get-token -p my-profile -f ClientCredentials
|
Silent output (for scripts):
1
| TOKEN=$(entratool get-token -p my-profile --silent)
|
Save to file:
1
| entratool get-token -p my-profile -o token.txt
|
JSON output:
1
| entratool get-token -p my-profile --json
|
Multiple scopes:
1
2
| entratool get-token -p my-profile \
--scope "https://graph.microsoft.com/User.Read,Mail.Read,Calendars.Read"
|
Device code flow:
1
| entratool get-token -p headless-server -f DeviceCode
|
Interactive browser:
1
| entratool get-token -p user-app -f InteractiveBrowser
|
Certificate authentication:
1
| entratool get-token -p cert-profile -f ClientCredentials
|
Full documentation →
Refresh an expired access token using a refresh token.
Synopsis link
1
| entratool refresh [OPTIONS]
|
| Option | Alias | Required | Description |
|---|
--profile <NAME> | -p | Yes | Profile name to use |
--silent | | No | Suppress output except token |
--output <FILE> | -o | No | Save token to file |
Examples link
Refresh token:
1
| entratool refresh -p my-profile
|
Silent output:
1
| TOKEN=$(entratool refresh -p my-profile --silent)
|
Save to file:
1
| entratool refresh -p my-profile -o token.txt
|
- Requires
offline_access scope in original token request - Not available for Client Credentials flow
- Refresh tokens expire after 90 days of inactivity
Full documentation →
Decode and display JWT token claims.
Synopsis link
1
| entratool inspect [OPTIONS]
|
| Option | Alias | Required | Description |
|---|
--token <TOKEN> | -t | Conditional | Token string to inspect |
--file <FILE> | -f | Conditional | File containing token |
Note: Provide either --token or --file, or pipe token via stdin.
Examples link
Inspect token string:
1
| entratool inspect -t "eyJ0eXAiOiJKV1Qi..."
|
Inspect from file:
1
| entratool inspect -f token.txt
|
Inspect from pipeline:
1
| entratool get-token -p my-profile --silent | entratool inspect
|
Extract specific claim:
1
| entratool inspect -t "$TOKEN" | jq -r .payload.scp
|
Check expiration:
1
| entratool inspect -t "$TOKEN" | jq -r .payload.exp
|
View all claims:
1
| entratool inspect -f token.txt | jq
|
Full documentation →
discover link
Quick token information and validation.
Synopsis link
1
| entratool discover [OPTIONS]
|
| Option | Alias | Required | Description |
|---|
--token <TOKEN> | -t | Conditional | Token string to discover |
--file <FILE> | -f | Conditional | File containing token |
Exit Codes link
0 - Token is valid1 - Token is expired or invalid
Examples link
Discover token info:
1
| entratool discover -t "eyJ0eXAiOiJKV1Qi..."
|
Check if token is valid:
1
2
3
4
5
| if entratool discover -t "$TOKEN" &>/dev/null; then
echo "Token is valid"
else
echo "Token is expired"
fi
|
From file:
1
| entratool discover -f token.txt
|
In script:
1
2
3
4
| if ! entratool discover -f token.txt; then
# Token expired, get new one
entratool get-token -p my-profile --silent > token.txt
fi
|
Full documentation →
Manage authentication profiles.
Synopsis link
1
| entratool config <SUBCOMMAND> [OPTIONS]
|
Subcommands link
| Subcommand | Description |
|---|
create | Create new profile |
list | List all profiles |
edit | Edit existing profile |
delete | Delete profile |
export | Export profile(s) |
import | Import profile(s) |
config create link
Create a new authentication profile interactively.
Synopsis:
1
| entratool config create
|
Example:
1
2
3
4
5
6
7
8
9
| entratool config create
# Interactive prompts:
# - Profile name
# - Client ID
# - Tenant ID
# - Authentication method
# - Scope
# - OAuth2 flow (optional)
|
config list link
List all configured profiles.
Synopsis:
1
| entratool config list [OPTIONS]
|
Options:
| Option | Description |
|---|
--json | Output as JSON |
Examples:
1
2
3
4
5
| # List profiles
entratool config list
# JSON output
entratool config list --json
|
config edit link
Edit an existing profile interactively.
Synopsis:
1
| entratool config edit [OPTIONS]
|
Options:
| Option | Alias | Required | Description |
|---|
--profile <NAME> | -p | Yes | Profile name to edit |
Example:
1
2
3
4
5
6
7
8
9
| entratool config edit -p my-profile
# Select what to edit:
# - Client ID
# - Tenant ID
# - Client Secret
# - Scope
# - OAuth2 Flow
# - Authority URL
|
config delete link
Delete a profile and its associated secrets.
Synopsis:
1
| entratool config delete [OPTIONS]
|
Options:
| Option | Alias | Required | Description |
|---|
--profile <NAME> | -p | Yes | Profile name to delete |
--force | | No | Skip confirmation |
Examples:
1
2
3
4
5
| # Delete with confirmation
entratool config delete -p my-profile
# Delete without confirmation
entratool config delete -p my-profile --force
|
config export link
Export profile configuration (without secrets).
Synopsis:
1
| entratool config export [OPTIONS]
|
Options:
| Option | Alias | Required | Description |
|---|
--profile <NAME> | -p | No | Profile name (omit for all) |
--output <FILE> | -o | Yes | Output file path |
Examples:
1
2
3
4
5
| # Export single profile
entratool config export -p my-profile -o profile.json
# Export all profiles
entratool config export -o all-profiles.json
|
config import link
Import profile configuration from file.
Synopsis:
1
| entratool config import [OPTIONS]
|
Options:
| Option | Alias | Required | Description |
|---|
--file <FILE> | -f | Yes | File to import |
Example:
1
| entratool config import -f profile.json
|
Full config documentation →
Display help information.
Synopsis link
1
2
| entratool --help
entratool <COMMAND> --help
|
Examples link
General help:
Command-specific help:
1
2
3
| entratool get-token --help
entratool config --help
entratool config create --help
|
--version link
Display version information.
Synopsis link
Output:
_ _ _
___ _ __ _ __| |_ _ __ __ _| |_ ___ ___ | |
/ _ \ '_ \| '__| __| '__/ _` | __/ _ \ / _ \| |
| __/ | | | | | |_| | | (_| | || (_) | (_) | |
\___|_| |_|_| \__|_| \__,_|\__\___/ \___/|_|
version 1.0.0
Global Options link
Available for all commands:
| Option | Description |
|---|
--help | Display help |
--version | Display version |
--verbose | Enable verbose output |
--no-color | Disable colored output |
Exit Codes link
| Code | Meaning |
|---|
0 | Success |
1 | General error |
2 | Invalid arguments |
3 | Authentication failed |
4 | Profile not found |
5 | Token expired |
6 | Network error |
Environment Variables link
| Variable | Description | Example |
|---|
AZURE_CLIENT_ID | Default client ID | 12345678-... |
AZURE_TENANT_ID | Default tenant ID | 87654321-... |
AZURE_CLIENT_SECRET | Client secret | abc123... |
ENTRATOOL_CONFIG_PATH | Config directory | ~/.entratool |
Configuration Files link
Profile Configuration link
Location: ~/.entratool/profiles.json
Format:
1
2
3
4
5
6
7
8
9
10
11
12
| {
"profiles": [
{
"name": "my-profile",
"clientId": "12345678-1234-1234-1234-123456789abc",
"tenantId": "87654321-4321-4321-4321-cba987654321",
"scope": "https://graph.microsoft.com/.default",
"flow": "ClientCredentials",
"useClientSecret": true
}
]
}
|
Secure Storage link
Secrets location:
- Windows: DPAPI-encrypted store
- macOS: Keychain (
~/Library/Keychains/login.keychain-db) - Linux:
~/.entratool/secrets.dat (⚠️ XOR obfuscated)
Common Command Patterns link
Script Integration link
1
2
3
4
5
6
7
8
9
| #!/bin/bash
set -euo pipefail
# Get token
TOKEN=$(entratool get-token -p automation --silent)
# Use token
curl -H "Authorization: Bearer $TOKEN" \
https://graph.microsoft.com/v1.0/me
|
Token Caching link
1
2
3
4
5
6
7
8
9
10
| TOKEN_FILE="/tmp/cached-token.txt"
# Check if token is valid
if ! entratool discover -f "$TOKEN_FILE" &>/dev/null; then
# Get fresh token
entratool get-token -p my-profile --silent > "$TOKEN_FILE"
chmod 600 "$TOKEN_FILE"
fi
TOKEN=$(cat "$TOKEN_FILE")
|
Multi-Environment link
1
2
3
4
5
6
7
8
| # Development
entratool get-token -p dev-profile -f ClientCredentials
# Staging
entratool get-token -p staging-profile -f ClientCredentials
# Production
entratool get-token -p prod-profile -f ClientCredentials
|
Error Handling link
1
2
3
4
5
6
7
8
| if ! TOKEN=$(entratool get-token -p my-profile --silent 2>&1); then
echo "Error: Failed to get token"
echo "$TOKEN"
exit 1
fi
# Use token
curl -H "Authorization: Bearer $TOKEN" ...
|
Next Steps link