Skip to content

Commit

Permalink
Gracefully exit on invalid github token
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcspadden committed Aug 31, 2023
1 parent 98dfb7c commit 9e43eb4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Code/autopkglib/apgithub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import os
import plistlib
import sys
from base64 import b64decode
from textwrap import dedent
from typing import Dict, List, Optional, Union
Expand Down Expand Up @@ -86,7 +87,11 @@ def __init__(
"WARNING: This is an unathenticated Github session, some API features may not work"
)
self.session = github.Github()
self.autopkg_org = self.session.get_organization("autopkg")
try:
self.autopkg_org = self.session.get_organization("autopkg")
except github.GithubException as err:
log_err(f"Your GitHub token exists but is invalid, please re-issue a new personal access token: {err}")
sys.exit(-1)
self.autopkg_repos = self.autopkg_org.get_repos(
type="public", sort="full_name", direction="asc"
)
Expand Down

0 comments on commit 9e43eb4

Please sign in to comment.