π OpenHands: AI-Driven Development
fix: use Auth.Token for PyGithub authentication (#12248)
Graham Neubig40c25cd1ce04
diff --git a/enterprise/integrations/github/data_collector.py b/enterprise/integrations/github/data_collector.pyindex 2d1f4b1b18..c6a9b4d6ae 100644--- a/enterprise/integrations/github/data_collector.py+++ b/enterprise/integrations/github/data_collector.py@@ -143,7 +143,7 @@ class GitHubDataCollector:try:installation_token = self._get_installation_access_token(installation_id)- with Github(installation_token) as github_client:+ with Github(auth=Auth.Token(installation_token)) as github_client:repo = github_client.get_repo(repo_name)issue = repo.get_issue(issue_number)comments = []@@ -237,7 +237,7 @@ class GitHubDataCollector:def _get_pr_commits(self, installation_id: str, repo_name: str, pr_number: int):commits = []installation_token = self._get_installation_access_token(installation_id)- with Github(installation_token) as github_client:+ with Github(auth=Auth.Token(installation_token)) as github_client:repo = github_client.get_repo(repo_name)pr = repo.get_pull(pr_number)diff --git a/enterprise/integrations/github/github_manager.py b/enterprise/integrations/github/github_manager.pyindex 8b5d9fc542..0d6d9d655f 100644--- a/enterprise/integrations/github/github_manager.py+++ b/enterprise/integrations/github/github_manager.py@@ -77,7 +77,7 @@ class GithubManager(Manager):reaction: The reaction to add (e.g. "eyes", "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket")installation_token: GitHub installation access token for API access"""- with Github(installation_token) as github_client:+ with Github(auth=Auth.Token(installation_token)) as github_client:repo = github_client.get_repo(github_view.full_repo_name)# Add reaction based on view typeif isinstance(github_view, GithubInlinePRComment):@@ -199,7 +199,7 @@ class GithubManager(Manager):outgoing_message = message.messageif isinstance(github_view, GithubInlinePRComment):- with Github(installation_token) as github_client:+ with Github(auth=Auth.Token(installation_token)) as github_client:repo = github_client.get_repo(github_view.full_repo_name)pr = repo.get_pull(github_view.issue_number)pr.create_review_comment_reply(@@ -211,7 +211,7 @@ class GithubManager(Manager):or isinstance(github_view, GithubIssueComment)or isinstance(github_view, GithubIssue)):- with Github(installation_token) as github_client:+ with Github(auth=Auth.Token(installation_token)) as github_client:repo = github_client.get_repo(github_view.full_repo_name)issue = repo.get_issue(number=github_view.issue_number)issue.create_comment(outgoing_message)diff --git a/enterprise/integrations/github/github_solvability.py b/enterprise/integrations/github/github_solvability.pyindex cdc6af05ec..3f2bdc17b5 100644--- a/enterprise/integrations/github/github_solvability.py+++ b/enterprise/integrations/github/github_solvability.py@@ -1,7 +1,7 @@import asyncioimport time-from github import Github+from github import Auth, Githubfrom integrations.github.github_view import (GithubInlinePRComment,GithubIssueComment,@@ -47,7 +47,7 @@ def fetch_github_issue_context(context_parts.append(f'Title: {github_view.title}')context_parts.append(f'Description:\n{github_view.description}')- with Github(user_token) as github_client:+ with Github(auth=Auth.Token(user_token)) as github_client:repo = github_client.get_repo(github_view.full_repo_name)issue = repo.get_issue(github_view.issue_number)if issue.labels:diff --git a/enterprise/integrations/github/github_view.py b/enterprise/integrations/github/github_view.pyindex a37ae04c33..c11eafb9ee 100644--- a/enterprise/integrations/github/github_view.py+++ b/enterprise/integrations/github/github_view.py@@ -735,7 +735,7 @@ class GithubFactory:payload['installation']['id']).token- with Github(access_token) as gh:+ with Github(auth=Auth.Token(access_token)) as gh:repo = gh.get_repo(selected_repo)login = (payload['organization']['login']@@ -872,7 +872,7 @@ class GithubFactory:access_token = integration.get_access_token(installation_id).tokenhead_ref = None- with Github(access_token) as gh:+ with Github(auth=Auth.Token(access_token)) as gh:repo = gh.get_repo(selected_repo)pull_request = repo.get_pull(issue_number)head_ref = pull_request.head.ref