Skip to content

Commit

Permalink
Merge pull request #60 from OpenRailAssociation/app-login-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmehl authored Dec 3, 2024
2 parents c573563 + e9c6935 commit 419bca5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gh_org_mgr/_gh_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ def login(

# Decide how to login. If app set, prefer this
if self.gh_app_id and self.gh_app_private_key:
logging.debug("Logged in via app %s", self.gh_app_id)
logging.debug("Logging in via app %s", self.gh_app_id)
auth = Auth.AppAuth(app_id=self.gh_app_id, private_key=self.gh_app_private_key)
app = GithubIntegration(auth=auth)
installation = app.get_installations()[0]
installation = app.get_org_installation(org=orgname)
self.gh = installation.get_github_for_installation()
logging.debug("Logged in via app installation %s", installation.id)

logging.debug("Getting access token for installation %s", installation.id)
self.gh_token = app.get_access_token(installation_id=installation.id).token
elif self.gh_token:
logging.debug("Logging in as user with PAT")
self.gh = Github(auth=Auth.Token(self.gh_token))
Expand All @@ -90,6 +94,7 @@ def login(
logging.error("No GitHub token or App ID+private key provided")
sys.exit(1)

logging.debug("Gathering data from organization '%s'", orgname)
self.org = self.gh.get_organization(orgname)
logging.debug("Gathered data from organization '%s' (%s)", self.org.login, self.org.name)

Expand Down

0 comments on commit 419bca5

Please sign in to comment.