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

"Must have admin rights" to delete a repo for which I have admin rights #176

Closed
timholy opened this issue Nov 30, 2020 · 3 comments
Closed

Comments

@timholy
Copy link
Collaborator

timholy commented Nov 30, 2020

I'm trying to do a mass deletion of old forks, and this package looks very useful. But I'm getting stuck here:

julia> frps[3]
Repo (all fields are Union{Nothing, T}):
  name: "ArrayFire.jl"
  full_name: "timholy/ArrayFire.jl"
  description: "Julia wrapper for the ArrayFire library"
  language: "Julia"
  default_branch: "master"
  owner: Owner("timholy")
  id: 65619845
  size: 202
  forks_count: 0
  stargazers_count: 0
  watchers_count: 0
  open_issues_count: 1
  url: HTTP.URI("https://api.github.com/repos/timholy/ArrayFire.jl")
  html_url: HTTP.URI("https://github.com/timholy/ArrayFire.jl")
  clone_url: HTTP.URI("https://github.com/timholy/ArrayFire.jl.git")
  ssh_url: HTTP.URI("git@github.com:timholy/ArrayFire.jl.git")
  homepage: HTTP.URI("")
  pushed_at: DateTime("2020-11-30T11:58:08")
  created_at: DateTime("2016-08-13T13:58:30")
  updated_at: DateTime("2019-04-10T22:35:26")
  has_issues: false
  has_wiki: false
  has_downloads: true
  has_pages: false
  private: false
  fork: true
  permissions: Dict{String,Any}("admin"=>true,"pull"=>true,"push"=>true)

Note the permissions field says "admin"=>true. But then

julia> delete_repo(frps[3]; auth=auth)
ERROR: Error found in GitHub reponse:
	Status Code: 403
	Message: Must have admin rights to Repository.
	Docs URL: https://docs.github.com/rest/reference/repos#delete-a-repository
	Errors: 
Stacktrace:
 [1] error(::String, ::String, ::String, ::String, ::String) at ./error.jl:42
 [2] handle_response_error(::HTTP.Messages.Response) at /home/tim/.julia/dev/GitHub/src/utils/requests.jl:177
 [3] github_request(::GitHub.GitHubWebAPI, ::Function, ::String; auth::GitHub.OAuth2, handle_error::Bool, headers::Dict{Any,Any}, params::Dict{Any,Any}, allowredirects::Bool) at /home/tim/.julia/dev/GitHub/src/utils/requests.jl:68
 [4] #gh_delete#7 at /home/tim/.julia/dev/GitHub/src/utils/requests.jl:75 [inlined]
 [5] delete_repo(::GitHub.GitHubWebAPI, ::Repo; options::Base.Iterators.Pairs{Symbol,GitHub.OAuth2,Tuple{Symbol},NamedTuple{(:auth,),Tuple{GitHub.OAuth2}}}) at /home/tim/.julia/dev/GitHub/src/repositories/repositories.jl:65
 [6] #delete_repo#67 at ./none:0 [inlined]
 [7] top-level scope at REPL[12]:1
@fredrikekre
Copy link
Member

fredrikekre commented Nov 30, 2020

Your token need specific permissions to allow this (https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#delete-a-repository), in particular you need to mark:
Screenshot from 2020-11-30 14-29-20

@timholy
Copy link
Collaborator Author

timholy commented Nov 30, 2020

That's it,thanks!

@timholy timholy closed this as completed Nov 30, 2020
@fredrikekre
Copy link
Member

The HTTP response from GitHub is a bit misleading.

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

2 participants