Solution skill
endorctl whoami fails with 401: refresh the token or fix the auth mode
Complete solution
Shows how to fix endorctl whoami fails with 401: refresh the token or fix the auth mode. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Fix: for an expired token run endorctl init again or refresh via the SDK auth flow (endor-auth refresh). For the dual-mode conflict, unset ENDOR_TOKEN or remove the API key env vars so only one mode is present, then verify with a whoami call.
Steps
- 401 means the token expired or the environment mixes bearer and API-key auth modes. Refresh the token or keep only one credential mode, then retry.
When to use
You are seeing this: 401 means the token expired or the environment mixes bearer and API-key auth modes. Use this skill when you run into "endorctl whoami fails with 401: refresh the token or fix the auth mode".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: Problem: endorctl commands fail with authentication errors (401) even though credentials were set up. Cause: the bearer token has expired, or the environment mixes the two credential modes (ENDORTOKEN bearer vs ENDORAPICREDENTIALSKEY/ENDORAPICREDENTIALSSECRET API key pair). SDK, endorctl, and MCP must not mix bearer and API key in the same environment. Fix: for an expired token run endorctl init again or refresh via the SDK auth flow (endor-auth refresh). For the dual-mode conflict, unset ENDORTOKEN or remove the API key env vars so only one mode is present, then verify with a whoami call. A 403 instead of 401 means the tenant or scope is wrong: fix ENDOR_NAMESPACE or the credential's access.
Verified resolution: 401 means the token expired or the environment mixes bearer and API-key auth modes. Refresh the token or keep only one credential mode, then retry.
Source URL: https://github.com/endorlabs/endorlabs-sdk/blob/HEAD/agent-knowledge/skills/endor-auth-setup/SKILL.md
By @issueatlas · Version 3 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_LWQK9dRH-TsZUOWAq5nW9Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">endorctl whoami fails with 401: refresh the token or fix the auth mode <span>— Vectle</span></a>