pygithub - how to create a check run?

380 views Asked by At

I am trying to create a check run in github (reference: )

import jwt
import time
from github import Github

pem_file = "ci-results.2020-11-27.private-key.pem"
installation_id = 13221707
app_id = 90466

time_since_epoch_in_seconds = int(time.time())
payload = {
    # issued at time
    'iat': time_since_epoch_in_seconds,
    # JWT expiration time (10 minute maximum)
    'exp': time_since_epoch_in_seconds + (5 * 60),
    # GitHub App's identifier
    'iss': app_id
}

this_jwt = jwt.encode(payload, open(pem_file, 'r').read().strip().encode(), 'RS256').decode()

gh = Github(jwt=this_jwt)

gh.get_app("ci-results")

# installation = gh.get_installation(installation_id)

# for repo in (installation.get_repos()):
#     print (repo)

I am getting the following error:

github.GithubException.BadCredentialsException: 401 {"message": "Bad credentials", "documentation_url": "https://docs.github.com/rest"}

I checked that JWT created is correct by using in REST API directly. I think I am not using the pyGitHUb correctly for JWT authentication, any idea what could I be doing wrong?

0

There are 0 answers