π OpenHands: AI-Driven Development
Offline session login (#7086)
chuckbutkusf12e9e94f76c
diff --git a/frontend/src/utils/generate-github-auth-url.ts b/frontend/src/utils/generate-github-auth-url.tsindex 9c9ad94afb..d6b9c80700 100644--- a/frontend/src/utils/generate-github-auth-url.ts+++ b/frontend/src/utils/generate-github-auth-url.ts@@ -2,6 +2,7 @@* Generates a URL to redirect to for GitHub OAuth* @param clientId The GitHub OAuth client ID* @param requestUrl The URL of the request+ * @param offline True for offline session, defaults to false* @returns The URL to redirect to for GitHub OAuth*/export const generateGitHubAuthUrl = (clientId: string, requestUrl: URL) => {@@ -10,6 +11,6 @@ export const generateGitHubAuthUrl = (clientId: string, requestUrl: URL) => {.replace(/(^|\.)staging\.all-hands\.dev$/, "$1auth.staging.all-hands.dev").replace(/(^|\.)app\.all-hands\.dev$/, "auth.app.all-hands.dev").replace(/(^|\.)localhost$/, "auth.staging.all-hands.dev");- const scope = "openid email profile offline_access";+ const scope = "openid email profile";return `https://${authUrl}/realms/allhands/protocol/openid-connect/auth?client_id=github&response_type=code&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(scope)}`;};diff --git a/openhands/integrations/github/github_service.py b/openhands/integrations/github/github_service.pyindex 72086e27ad..47552ef458 100644--- a/openhands/integrations/github/github_service.py+++ b/openhands/integrations/github/github_service.py@@ -26,8 +26,10 @@ class GitHubService:user_id: str | None = None,idp_token: SecretStr | None = None,token: SecretStr | None = None,+ external_token_manager: bool = False,):self.user_id = user_id+ self.external_token_manager = external_token_managerif token:self.token = tokendiff --git a/openhands/runtime/base.py b/openhands/runtime/base.pyindex 921d3b471d..6a2ce91a8f 100644--- a/openhands/runtime/base.py+++ b/openhands/runtime/base.py@@ -221,7 +221,9 @@ class Runtime(FileEditRuntimeMixin):try:if isinstance(event, CmdRunAction):if self.github_user_id and '$GITHUB_TOKEN' in event.command:- gh_client = GithubServiceImpl(user_id=self.github_user_id)+ gh_client = GithubServiceImpl(+ user_id=self.github_user_id, external_token_manager=True+ )token = await gh_client.get_latest_provider_token()if token:export_cmd = CmdRunAction(