Closed rshawnkeller closed 3 years ago
What is the difficulty?/What have you tried so far?
although this library has a good set of documentation, i have not found any examples that show how to grab a token or use it.
grab a token from what? and you'd use the token exactly how you would in any other http client...
trying to get an oauth 2 token (grant_type = password) from an API that requires it, using lua, unfortunately. yes, most clients like ruby, java, postman, etc., it is easy, but lua is not where those other languages or have the community behind them. just looking for a code sample
local request = require('http.request')
local util = require('http.util')
local req = request.new_from_uri('https://your-oauth-endpoint')
req.headers:upsert(':method','POST')
req.headers:upsert('somekind-of-header','some-kind-of-header-value')
req:set_body(util.dict_to_query({some_param = some_value, some_other_param = some_other_value}))
local headers, stream = req:go()
local body, err = stream:get_body_as_string()
do_stuff_with(body)
At the end of the day it's just making an HTTP request, to an endpoint, with some headers
@jprjr Thanks for the example, I have been looking all day now, wondering where I can find an article or tutorial to show how an HTTP request is constructed to do REST API, I mean I know how to use client and such, but how the REST client composed it and make the HTTP request.
I hope if you can help me find a good tutorial, article, or give me the right terminology to look for this stuff
does anyone have an example of making a simple API endpoint call , with an Oauth2 Bearer token?