When you connect an MCP client to etlmcp with OAuth, the client holds two tokens: a short-lived access token that starts with eto_ and goes on every request to /mcp, and a longer-lived refresh token that starts with etr_ and is used only to get a new pair. Your client swaps its refresh token for a new pair before the access token runs out, so you never notice. You have to approve the app again only when the grant behind those tokens is gone: it was revoked, its user lost access to the workspace or left the organization, a token was reused, or the refresh token itself expired because the client did not use it in time.
The three credentials and how long each lives
- Authorization code. etlmcp issues it once you approve the app on the consent page, and the client trades it for tokens. It lives only a few minutes and works once.
- Access token (
eto_…). It authenticates each call to/mcp. The token response tells the client how long it lasts, in seconds, in itsexpires_infield. - Refresh token (
etr_…). It lasts much longer than the access token. Each time the client uses it, etlmcp marks it used and hands back a new access token and a new refresh token. The client must keep the new refresh token and throw the old one away.
etlmcp stores only a SHA-256 hash of each code and token, so a lost token cannot be read back from etlmcp, only replaced by approving the app again.
Why an agent suddenly gets a 401
A call to /mcp with a token etlmcp no longer accepts gets HTTP 401 with the body invalid or missing credentials. The WWW-Authenticate header adds error="invalid_token" and names etlmcp's protected-resource metadata, so the client can find the authorization server and start again. An access token is refused when:
- it has expired and the client did not refresh it;
- it was revoked on its own, or its whole grant was revoked;
- the user who approved the app no longer reaches the grant's workspace, or is no longer a member of the organization.
The last two are checked on every request, not only when the token was issued. When a member is removed from the organization or from the workspace, a database trigger revokes their grants and tokens at once.
If only the access token expired, the client should refresh and carry on. If the refresh fails, the client has to send you through the consent page again.
What the token endpoint answers
When the client sends a complete request but etlmcp refuses the code or the refresh token in it, the answer is an invalid_grant error with HTTP 400, the error RFC 6749 names for a grant or refresh token that is invalid, expired or revoked. A request with a missing field gets invalid_request instead. The error_description says which case it is:
| Description | What happened | What you do |
|---|---|---|
authorization code expired |
The client waited too long before redeeming the code. | Start the connection again from the client. |
authorization code already used |
The same code was presented a second time. | Approve the app again. |
refresh token expired |
The client did not refresh within the refresh token's lifetime. | Approve the app again. |
refresh token already used |
The refresh token was revoked: it was already swapped, or the app was disconnected, or its user was removed from the workspace or the organization, which revokes every token of the grant. | Approve the app again, as a user who still has access. |
grant revoked |
The grant behind the code or the token was revoked, or its user no longer reaches the grant's workspace. | Approve the app again, as a user who still has access. |
A housekeeping job deletes expired tokens and, some time after they expire, old authorization codes. A token or code that is gone, or one etlmcp never issued, is answered with unknown refresh token or unknown authorization code instead, and you approve the app again.
Reuse is treated as theft
RFC 6749 describes refresh token rotation as a way to spot a stolen token: if both the real client and an attacker hold the same refresh token, one of them eventually presents a token that was already replaced. etlmcp acts on that signal. A second use of an authorization code, or of a refresh token that was already rotated or revoked, revokes the whole grant and every token it issued, and the revocation stands even though the request itself fails. The real client then loses access too, and you have to approve it again.
This is why two copies of one client must not share a refresh token. If you copy a client's saved credentials to a second machine, the first refresh on one machine makes the other machine's token stale, and its next refresh ends the grant for both.
Ending a connection on purpose
- On the API page in the app, the Connected apps table lists each approved app. You can press Disconnect on an app you approved, and an owner can disconnect any of them. It stops working at once.
- A client can revoke a token itself at
/oauth/revoke. Revoking an access token ends only that token; revoking a refresh token ends the whole grant.
For a credential that does not expire on a schedule, such as for a script or a header-based client, use an API key instead. How the client finds etlmcp and what you approve is on Connecting an MCP client with OAuth, and the tools it can then call are on the MCP reference.