cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.38k stars 151 forks source link

server returned 403 Forbidden #104

Open Prateeknandle opened 10 months ago

Prateeknandle commented 10 months ago
resp, err := grab.Get(".", "some-zip-file")
    if err != nil {
        log.Info(err)
    }

This gives the error server returned 403 Forbidden Try with https://github.com/cavaliergopher/grab/archive/refs/tags/v3.0.1.zip, it'll show you the error

cfergeau commented 9 months ago

I've only seen this happen on downloads from github, and it's caused by the default user agent (which is "grab"), not sure why it's blocked. Changing it to anything else solves this issue. In your example, this can be achieved by adding grab.DefaultClient.UserAgent="non-default-user-agent" before the call to grab.Get