Summary of findings about access_token
• What it is: In the OSS backend, access_token is an optional external auth token for the current request, surfaced by the user-auth layer. By default (OSS), it’s always None; it exists to keep the same API surface that Enterprise/SaaS needs.
◦ Plumbed via get_access_token(request): openhands/server/user_auth/*init*.py#L18-L21
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/user_auth/__init__.py#L18-L21
◦ Default implementation returns None: openhands/server/user_auth/default_user_auth.py#L32-L34
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/user_auth/default_user_auth.py#L32-L34
• What purpose it serves: Routes accept access_token and forward it to ProviderHandler as external_auth_token so provider services can authenticate using an external identity provider (used in Enterprise). In OSS, services still build headers from stored provider tokens (PATs), so access_token is effectively unused there.
◦ ProviderHandler ctor stores external_auth_token: openhands/integrations/provider.py#L113-L121, L134, L154-L160
<https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/integrations/provider.py#L113-L121
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/integrations/provider.py#L154-L160>
◦ OSS services construct headers from self.token (PAT), not external_auth_token:
▪︎ GitHub: openhands/integrations/github/service/base.py#L24-L35
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/integrations/github/service/base.py#L24-L35
▪︎ GitLab: openhands/integrations/gitlab/service/base.py#L23-L33
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/integrations/gitlab/service/base.py#L23-L33
▪︎ Bitbucket: openhands/integrations/bitbucket/service/base.py#L51-L67
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/integrations/bitbucket/service/base.py#L51-L67
• All related execution flows/routes in OSS that take and forward access_token:
◦ User routes: installations, repositories, info, search/repositories, search/branches, suggested-tasks, repository/branches, repository/{repo}/microagents, and repository/{repo}/microagents/content. Each has access_token = Depends(get_access_token) and passes it to ProviderHandler(external_auth_token=…):
<https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/git.py#L42
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/git.py#L73
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/git.py#L108
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/git.py#L140
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/git.py#L174
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/git.py#L213
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/git.py#L245
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/git.py#L299
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/git.py#L365>
◦ MCP tools (create PR/MR): acquire access_token via get_access_token and forward it into Github/GitLab/Bitbucket services:
▪︎ GitHub PR: openhands/server/routes/mcp.py#L104-L121
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/mcp.py#L104-L121
▪︎ GitLab MR: openhands/server/routes/mcp.py#L175-L191
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/mcp.py#L175-L191
▪︎ Bitbucket PR: openhands/server/routes/mcp.py#L242-L257
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/openhands/server/routes/mcp.py#L242-L257
• Enterprise/SaaS context (why OSS carries it): In Enterprise, access_token is the Keycloak access token. SaasUserAuth refreshes/returns it, and provider services translate it into actual provider tokens via Keycloak broker endpoints—so the same OSS routes work without code changes.
◦ SaasUserAuth.get_access_token: enterprise/server/auth/saas_user_auth.py#L130-L139
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/enterprise/server/auth/saas_user_auth.py#L130-L139
◦ Broker token fetch: enterprise/server/auth/token_manager.py#L204-L211
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/enterprise/server/auth/token_manager.py#L204-L211
◦ SaaS GitHub service uses access_token to get a working GitHub token: enterprise/integrations/github/github_service.py#L39-L47
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/enterprise/integrations/github/github_service.py#L39-L47
◦ Enterprise README (OSS vs Enterprise auth): enterprise/README.md#L29-L35
https://github.com/All-Hands-AI/OpenHands/blob/fdf8b21b845a47c0970f16641b9234deec1ddfe6/enterprise/README.md#L29-L35
Net: In OSS, access_token is a no-op hook; in Enterprise, it’s the Keycloak bearer used to mint/refresh real provider tokens, which is why the OSS code paths accept and pass it through.
<sub>
View full conversation</sub>