mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-06 21:44:00 -05:00
fix: use Auth.Token for PyGithub authentication (#12248)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -143,7 +143,7 @@ class GitHubDataCollector:
|
|||||||
try:
|
try:
|
||||||
installation_token = self._get_installation_access_token(installation_id)
|
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)
|
repo = github_client.get_repo(repo_name)
|
||||||
issue = repo.get_issue(issue_number)
|
issue = repo.get_issue(issue_number)
|
||||||
comments = []
|
comments = []
|
||||||
@@ -237,7 +237,7 @@ class GitHubDataCollector:
|
|||||||
def _get_pr_commits(self, installation_id: str, repo_name: str, pr_number: int):
|
def _get_pr_commits(self, installation_id: str, repo_name: str, pr_number: int):
|
||||||
commits = []
|
commits = []
|
||||||
installation_token = self._get_installation_access_token(installation_id)
|
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)
|
repo = github_client.get_repo(repo_name)
|
||||||
pr = repo.get_pull(pr_number)
|
pr = repo.get_pull(pr_number)
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class GithubManager(Manager):
|
|||||||
reaction: The reaction to add (e.g. "eyes", "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket")
|
reaction: The reaction to add (e.g. "eyes", "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket")
|
||||||
installation_token: GitHub installation access token for API access
|
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)
|
repo = github_client.get_repo(github_view.full_repo_name)
|
||||||
# Add reaction based on view type
|
# Add reaction based on view type
|
||||||
if isinstance(github_view, GithubInlinePRComment):
|
if isinstance(github_view, GithubInlinePRComment):
|
||||||
@@ -199,7 +199,7 @@ class GithubManager(Manager):
|
|||||||
outgoing_message = message.message
|
outgoing_message = message.message
|
||||||
|
|
||||||
if isinstance(github_view, GithubInlinePRComment):
|
if 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)
|
repo = github_client.get_repo(github_view.full_repo_name)
|
||||||
pr = repo.get_pull(github_view.issue_number)
|
pr = repo.get_pull(github_view.issue_number)
|
||||||
pr.create_review_comment_reply(
|
pr.create_review_comment_reply(
|
||||||
@@ -211,7 +211,7 @@ class GithubManager(Manager):
|
|||||||
or isinstance(github_view, GithubIssueComment)
|
or isinstance(github_view, GithubIssueComment)
|
||||||
or isinstance(github_view, GithubIssue)
|
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)
|
repo = github_client.get_repo(github_view.full_repo_name)
|
||||||
issue = repo.get_issue(number=github_view.issue_number)
|
issue = repo.get_issue(number=github_view.issue_number)
|
||||||
issue.create_comment(outgoing_message)
|
issue.create_comment(outgoing_message)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from github import Github
|
from github import Auth, Github
|
||||||
from integrations.github.github_view import (
|
from integrations.github.github_view import (
|
||||||
GithubInlinePRComment,
|
GithubInlinePRComment,
|
||||||
GithubIssueComment,
|
GithubIssueComment,
|
||||||
@@ -47,7 +47,7 @@ def fetch_github_issue_context(
|
|||||||
context_parts.append(f'Title: {github_view.title}')
|
context_parts.append(f'Title: {github_view.title}')
|
||||||
context_parts.append(f'Description:\n{github_view.description}')
|
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)
|
repo = github_client.get_repo(github_view.full_repo_name)
|
||||||
issue = repo.get_issue(github_view.issue_number)
|
issue = repo.get_issue(github_view.issue_number)
|
||||||
if issue.labels:
|
if issue.labels:
|
||||||
|
|||||||
@@ -735,7 +735,7 @@ class GithubFactory:
|
|||||||
payload['installation']['id']
|
payload['installation']['id']
|
||||||
).token
|
).token
|
||||||
|
|
||||||
with Github(access_token) as gh:
|
with Github(auth=Auth.Token(access_token)) as gh:
|
||||||
repo = gh.get_repo(selected_repo)
|
repo = gh.get_repo(selected_repo)
|
||||||
login = (
|
login = (
|
||||||
payload['organization']['login']
|
payload['organization']['login']
|
||||||
@@ -872,7 +872,7 @@ class GithubFactory:
|
|||||||
access_token = integration.get_access_token(installation_id).token
|
access_token = integration.get_access_token(installation_id).token
|
||||||
|
|
||||||
head_ref = None
|
head_ref = None
|
||||||
with Github(access_token) as gh:
|
with Github(auth=Auth.Token(access_token)) as gh:
|
||||||
repo = gh.get_repo(selected_repo)
|
repo = gh.get_repo(selected_repo)
|
||||||
pull_request = repo.get_pull(issue_number)
|
pull_request = repo.get_pull(issue_number)
|
||||||
head_ref = pull_request.head.ref
|
head_ref = pull_request.head.ref
|
||||||
|
|||||||
Reference in New Issue
Block a user