0

I'm trying to implement OAuth 2.0 into computercraft, and to do so, I have to make the following request:

http.post("https://accounts.google.com/o/oauth2/device/code", "client_id={my id here}&scope=email")

and I'm just getting a Could not connect error

After doing some testing, I found that http.checkUrl() works with this url, it works using curl in terminal, and http.get("https://accounts.google.com") works as well. It seems like the only reason this isn't working is because computercraft isn't handling POST requests properly.

What's weird is that http.get("https://accounts.google.com/o.oauth2/device/code") doesn't work either, which is really confusing. Although this isn't a valid request, it should succeed with a response of {"error":"Invalid request"}, which it does when I use curl.

Am I doing something wrong here, or is there some sort of work around?

Potassium Ion
  • 2,075
  • 1
  • 22
  • 39

2 Answers2

0

Depending on your configuration you may need to enable the ComputerCraft HTTP API. Or you may need to white-list the accounts.google.com domain. You can also disable white-listing altogether if it's enabled.

You can find the settings it in the config\ComputerCraft.cfg file.

HTTP posts do work. I am not 100% sure about HTTPS though.

  • As mentioned in the OP, I can request `https://accounts.google.com` perfectly fine. It's that specific url that isn't working. – Potassium Ion May 07 '16 at 01:25
  • @tupperkion maybe checkUrl skips the white-listing or something... I have noticed CC doesn't handle error responses too well, does your curl request give a 200? –  May 08 '16 at 10:41
  • @tupperkion CC Wiki is up again: checkUrl does check the whitelist it says. It however does not try to connect, firewall thing? You can do a http.get anywhere else right? –  May 08 '16 at 10:44
  • Yeah, and checkurl says the url I'm trying to request is valid – Potassium Ion May 13 '16 at 19:00
0

For debugging setup an os.PullEvent()

Use the http_failure for sorting

If it still does not work, change the whitelist in your config\ComputerCraft.cfg

whitelist = *

Or whatever the configuration format is

user298329
  • 13
  • 5