-->
Page 1 of 1

HTTPS Post with Bearer Token Authorization

PostPosted: Tue Mar 08, 2016 12:37 am
by phando
Hey All,
I am trying to love the NodeMCU chip but keep hitting issues at every turn. Currently I am trying to make an HTTPS Post with Bearer Token Authorization. If you have an example of making this kind of request using ArduinoIDE or ESPolorer I would love to see the syntax.

Thanks!

Re: HTTPS Post with Bearer Token Authorization

PostPosted: Fri Mar 25, 2016 1:59 pm
by phando
Got it! :D
Turns out making https requests needs some custom firmware. Turns out there is a great resource for making custom firmware. http://nodemcu-build.com by selecting a dev build, I was able to add http with https support and successfully make my https post.

Code: Select allbody = '{"Team":1, "Item1":2, "Item2":3, "Item3":4}'

http.post('https://SOME_ENDPOINT_URL',
    'Content-Type: application/json\r\n'
  ..'Authorization: Bearer SOME_CRAZY_AUTH_KEY\r\n'
  ..'Accept-Encoding: gzip, deflate\r\n',
  body,
  function(code, data)
    if (code < 0) then
      print("HTTP request failed")
    else
      print(code, data)
    end
  end)