Giter Site home page Giter Site logo

Comments (6)

jamestoyer avatar jamestoyer commented on May 31, 2024

@lukehinds have you tried client.Client()? This should return you an instance of the underlying HTTP client with the correct middleware to do an authenticated request.

from go-githubapp.

lukehinds avatar lukehinds commented on May 31, 2024

Hey @jamestoyer , nice tip off, but it seems no dice.

clientConnection := client.Client()
resp, _ := clientConnection.Get(downloadURL)
fmt.Println("Status: ", resp.StatusCode)

This gives me a 404 Not Found. I know the asset is there though, as when I change the repo from private to public, I can access the release asset with no problem.

from go-githubapp.

jamestoyer avatar jamestoyer commented on May 31, 2024

I guess I'm a little confused as to why you're trying to use the browser_download_url. I suspect the reason this is failing when it's private is that it doesn't actually understand the auth tokens and probably only understands cookie auth.

from go-githubapp.

lukehinds avatar lukehinds commented on May 31, 2024

Yes, I agree, this is confusing on my part.

Tokens only work with https://api.github.com not https://github.com/owner/repo/releases/download/

Butbrowser_download_url is the only direct access that GitHub provides to retrieve a release asset.

Sorry about the noise here, but seems this is an invalid / outside issue. I need to dig into githubs API a bit more.

from go-githubapp.

lukehinds avatar lukehinds commented on May 31, 2024

A bit further along, turns out you need an Accept header of application/octet-stream and if you do, GitHub redirects (and gives your actual file).

I found this out by debugging with curl, with the -L flag, you don't get the file. I just need to figure out how to wire in http.Client.CheckRedirect now

Sorry for the noise again, I will make sure I close this, but I figure it might be of use to someone in the future.

from go-githubapp.

lukehinds avatar lukehinds commented on May 31, 2024

Right, a little more digging reveals that there is a DownloadReleaseAsset which can handle GitHubs redirect.

I need to figure out how to populate an accept application/octet-stream into client.Client()

from go-githubapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.