mingrammer/go-web-framework-stars

Wrong assumption from the access_token.txt file

leobm opened this issue · 0 comments

leobm commented

Hi MinJae,

I wanted to create the Go Framework list locally, because I thought it would be fun to play around with the github API. Unfortunately I came across something that took me some time to find out about because I didn't understand it right away. I added my personal access token from github to the file access_token.txt. Then I got a forbitten 403 error back pretty quickly after running list2md.go. The problem was that the "Authorization" header should basically look like this.
"token [MY_GITHUB_ACCESS_TOKEN].

You probably have this (with the keyword token) in your access_token.txt? But that was not immediately obvious to me if you don't know it.
Maybe it makes sense to use the following in the code:
req.Header.Set("Authorization", "token "+accessToken)
Or that would need to be documented somewhere?

A second thing I noticed, according to the documentation on Github you are also "obliged" to send a user agent header. This header should contain your own username.

All API requests MUST include a valid User-Agent header. Requests with no User-Agent header will be rejected. We request that you use your GitHub username, or the name of your application, for the User-Agent header value. This allows us to contact you if there are problems.

It seems to work without this header. But maybe you should add that too? But then the username would have to be read from a file too?

regards,
Felix