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

403 You need admin access to the organization before adding a repository to it. #477

Open
jedbrown opened this issue Jan 13, 2022 · 7 comments

Comments

@jedbrown
Copy link
Contributor

abc-init says my token is valid. The account is an owner of the organization where I want to create the template repository, but abc-new-template reponame --github fails. Do you know what's wrong or how to provide a more useful error message?

Traceback (most recent call last):
  File "/home/jovyan/.local/bin/abc-new-template", line 8, in <module>
    sys.exit(new_template())
  File "/home/jovyan/.local/lib/python3.9/site-packages/abcclassroom/__main__.py", line 158, in new_template
    template.new_update_template(args)
  File "/home/jovyan/.local/lib/python3.9/site-packages/abcclassroom/template.py", line 34, in new_update_template
    create_template(
  File "/home/jovyan/.local/lib/python3.9/site-packages/abcclassroom/template.py", line 135, in create_template
    create_or_update_remote(
  File "/home/jovyan/.local/lib/python3.9/site-packages/abcclassroom/template.py", line 167, in create_or_update_remote
    abcgithub.create_repo(organization, repo_name, token)
  File "/home/jovyan/.local/lib/python3.9/site-packages/abcclassroom/github.py", line 50, in create_repo
    organization.create_repository(repository)
  File "/home/jovyan/.local/lib/python3.9/site-packages/github3/decorators.py", line 24, in auth_wrapper
    return func(self, *args, **kwargs)
  File "/home/jovyan/.local/lib/python3.9/site-packages/github3/orgs.py", line 637, in create_repository
    json = self._json(self._post(url, data), 201)
  File "/home/jovyan/.local/lib/python3.9/site-packages/github3/models.py", line 153, in _json
    raise exceptions.error_for(response)
github3.exceptions.ForbiddenError: 403 You need admin access to the organization before adding a repository to it.
@lwasser
Copy link

lwasser commented Jan 13, 2022

oh @jedbrown this is a quick guess...
are the permissions on the key set on your hub? i kind of remember running into this and a quick chmod operation did the trick. this was specific to working on the jhub vs local. this is just a guess if you are certain you in fact have the correct github permissions and the ssh key is in fact setup.

#315 (comment)

my fix:
chmod 400 /home/jovyan/.ssh/id_rsa

in case this happens to work, i had added some discussion in the docs.

@jedbrown
Copy link
Contributor Author

Thanks for your quick reply. My key is 0600 and it works fine when used manually. Indeed, I worked around this issue by just setting the remote manually and git push origin main. But I think this error is with the API token, which I'm less familiar with, to create the repository (which can't be done via ssh).

@lwasser
Copy link

lwasser commented Jan 14, 2022

got it. thought i'd try permissions first. @kcranston setup that token. i haven't tried to create a repo and push from a hub but we can try to recreate it locally to see if we run into the same issue. Just out of curiosity did you encounter the same issue running it locally on your computer?

It also seems like it would be helpful for it to print out what organization and repo it's trying to access just in case the user has their config setup to connect to the incorrect place too. let me see - @eculler have you used abc-classroom to create template repos? did you run into permissions issues?

@eculler
Copy link
Collaborator

eculler commented Jan 19, 2022

@lwasser yes, I have, and no I didn't have any permissions issues

@neurorepro
Copy link

As @jedbrown mentioned, the first idea is that it is due to the API token, and i can confirm it is. I got the same error and could fix it by generating myself a token with all repo permissions and then putting this token in ~/.abc-classroom.tokens.yml to replace the one generated from abc-init.

@lwasser
Copy link

lwasser commented Oct 25, 2022

i'm unfortunately not sure who is maintaining this package anymore.

see here at the top: https://github.com/earthlab/abc-classroom/blob/main/README.md

If you setup your own token then does abc-classroom function as expected?

@neurorepro
Copy link

I see, i also submitted a PR on a separate issue.

Yes it works as expected with a custom token.

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

4 participants