Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, server: ni_abc.ServerHost, client: aiohttp.ClientSession,
event: PullRequestEvent,
request: JSONDict) -> None:
"""Represent a contribution."""
self.server = server
self.event = event
self.request = request
self._gh = GitHubAPI(client, "the-knights-who-say-ni",
oauth_token=server.contrib_auth_token())
async def main():
async with aiohttp.ClientSession() as session:
app_id = os.getenv("GH_APP_ID")
jwt = get_jwt(app_id)
gh = GitHubAPI(session, "Mariatta")
try:
installation = await get_installation(gh, jwt, "Mariatta")
except ValueError as ve:
# Raised if Mariatta did not installed the GitHub App
print(ve)
else:
access_token = await get_installation_access_token(
gh, jwt=jwt, installation_id=installation["id"]
)
# treat access_token as if a personal access token
# Example, creating a GitHub issue as a GitHub App
gh_app = GitHubAPI(session, "black_out", oauth_token=access_token["token"])
def create_api_object(self, session: aiohttp.ClientSession,
requester: str, *args, **kwargs) -> None:
self.api = gidgethub.aiohttp.GitHubAPI(
session, requester, oauth_token=self.token,
cache=cachetools.LRUCache(maxsize=500)
)
self.session = session
def load(self, sirbot):
LOG.info("Loading github plugin")
self.api = GitHubAPI(session=sirbot.http_session, requester=sirbot.user_agent)
sirbot.router.add_route("POST", "/github", dispatch)