JuliaWeb / GitHub.jl

A Julia package for interfacing with GitHub
MIT License
172 stars 60 forks source link

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

Closed timholy closed 3 years ago

timholy commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

That's it,thanks!

fredrikekre commented 3 years ago

The HTTP response from GitHub is a bit misleading.