Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Projects NOT Showing Up #2967

Open
LorenzoCattai opened this issue May 9, 2024 · 2 comments
Open

User Projects NOT Showing Up #2967

LorenzoCattai opened this issue May 9, 2024 · 2 comments

Comments

@LorenzoCattai
Copy link

LorenzoCattai commented May 9, 2024

I am trying to access my GitHub projects but they do not seem to exists according to PyGithub.

This is the code I'm trying to run (GITHUB_TOKEN censored):

from github import Github

github = Github(GITHUB_TOKEN)

for repository in github.get_user().get_repos():
    print(repository.name)
    for project in repository.get_projects():
        print(project.name)

It only prints out the name of my repositories but not a single project name.

So I tried to get the project directly usign github.get_project() like this (GITHUB_TOKEN censored):

from github import Github

github = Github(GITHUB_TOKEN)

project = github.get_project(1)
print(project.name)

But this errors out with:

Request GET /projects/1 failed with 403: Forbidden
Traceback (most recent call last):
  File "c:\Users\user\test\main.py", line 22, in <module>
    project = github.get_project(1)
              ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\github\MainClass.py", line 464, in get_project
    headers, data = self.__requester.requestJsonAndCheck(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\github\Requester.py", line 548, in requestJsonAndCheck    
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\github\Requester.py", line 713, in requestJson
    return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\github\Requester.py", line 810, in __requestEncode        
    status, responseHeaders, output = self.__requestRaw(cnx, verb, url, requestHeaders, encoded_input)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\github\Requester.py", line 844, in __requestRaw
    response = cnx.getresponse()
               ^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\github\Requester.py", line 196, in getresponse
    r = verb(
        ^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 938, in urlopen
    retries = retries.increment(method, url, response=response, _pool=self)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\github\GithubRetry.py", line 185, in increment
    raise Requester.createException(response.status, response.headers, content)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
github.GithubException.GithubException: 403 {"message": "Must have admin rights to Repository.", "documentation_url": "https://docs.github.com/rest/projects/projects#get-a-project"}

I have tried both code snippets with classic tokens and fine grained tokens (with all scopes enabled) from the repository and project owner user but the result is the same.

@LorenzoCattai
Copy link
Author

LorenzoCattai commented May 9, 2024

From further research it seems that there is a different api for classic projects and (new) projects, I'm guessing all new github projects are now of the new type by default so that's why none of mine are showing up, PyGithub is only using the old API for projects is seems, #2405 talks about the new api, it seems they called it ProjectsV2 and it uses GraphQL instead us RESTful.

@LorenzoCattai
Copy link
Author

LorenzoCattai commented May 9, 2024

This Issue could be potentially considered a duplicate of #2140 as that Issue asks for support for the new api while I was just reporting the fact that new github projects are not showing up when using PyGithub, tho that Issue should probably get renamed to just Support for (new) projects or something similar as I believe it's not in beta anymore if this new project type is what github created on my repositories by default.

@LorenzoCattai LorenzoCattai changed the title User Projects not showing up. User Projects not showing up May 9, 2024
@LorenzoCattai LorenzoCattai changed the title User Projects not showing up User Projects NOT Showing Up May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant