1

Am trying to scrape data from a private repo by using GitHub's API via the Google Apps Script (GAS).

I have an accessToken that seems to work for normal things, but when it comes to doing searches for issues, the accessToken is not accepted.

https://api.github.com/search/issues?q=repo:esaruoho/ztracker_mac+state:open (+aT)

I'm trying to access a private repo (not the one I linked here, which is public, and the link works) and attach the

?access_token=token

at the end, but for some reason this simply does not seem to work. Is there some other way of authentication?

I'm trying to figure out how I could modify the UrlFetchApp.fetch to also input the required headers that authenticate, but I'm not figuring out what kind of stuff GitHub authenticates with

esaruoho
  • 896
  • 1
  • 7
  • 25
  • What error code do you get when you try to run your request? – Kos Jul 25 '17 at 11:04
  • @Kos [17-07-25 15:16:35:841 EEST] {"message":"Validation Failed","errors":[{"message":"The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.","resource":"Search","field":"q","code":"invalid"}],"documentation_url":"https://developer.github.com/v3/search/"} – esaruoho Jul 25 '17 at 12:16
  • Check result of call to `https://api.github.com/repos/USER/REPO`, what does it say? – Kos Jul 25 '17 at 12:27
  • @Kos hi, turns out the issue was that the ?access_token= was supposed to be &access_token= -- once you switch the question mark to an ampersand, everything works beautifully. – esaruoho Jul 25 '17 at 14:08
  • When you generated your access token which scopes did you authorize? I suspect you may need to authorize more scopes on the token before you can use it to do issue searches. – TheAddonDepot Jul 25 '17 at 14:08
  • @DimuDesigns except that if the URL is not supposed to have multiple questionmarks, instead one questionmark - then other questionmarks replaced by ampersand (&) then no matter which types of tokens and scopes I've edited, the fully functioning token is simply not going to work. – esaruoho Jul 25 '17 at 14:09

1 Answers1

0

Here's what you are trying to do:

https://api.github.com/search/issues?q=repo:esaruoho/ztracker_mac+state:open?access_token=yourToken

Notice how you already have a question mark (?) in the URL, you can't put two in, you have to change the question mark to an ampersand (&)

https://api.github.com/search/issues?q=repo:esaruoho/ztracker_mac+state:open&access_token=yourToken
esaruoho
  • 896
  • 1
  • 7
  • 25